VBA Auto Sort when formula result changes

tahazameel

New Member
Joined
Oct 28, 2020
Messages
2
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I'm a beginner at VBA. I'm trying to create a function where I calculate the averages of some scores, and then transfer the scores to a 'sheet' adjacent to it.
In this sheet, I transferred over the Adjacent Ratings calculated in Row C to Row H simply by giving Row H formulas, such as selecting H2 and giving it the formula of =C12 etc to correspond to the category.

I then used this code to sort Out the AVERAGE RATINGS sheet by ascending order.

Private Sub Worksheet_Change(ByVal Target As Range)
Range("F2:H4").Sort Key1:=Range("H2"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End Sub

However, when I do this, and the ratings under Column H get sorted, I find that the formulas of each average rating doesn't match what I had originally input.

For example, I input the average rating formula for Ease of Finding Way Through Airport's as =C12 under column H.
However, when the ratings get sorted, I find that the average rating formula for Ease of Finding Way Through Airport automatically changes to something like =C13 or =C14 or =C12 instead. This in turn changes the value as well.

I apologise for my poor explanation. I'm not a native English speaker.
How do I solve this issue?




1603865207041.png
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
ENGLISH EDIT:
I'm a beginner at VBA. I'm trying to create a function where I calculate the averages of some scores, and then transfer the scores to a 'sheet' adjacent to it.
In this sheet, I transferred over the Adjacent Ratings calculated in Column C to Column H simply by giving Column H formulas, such as selecting H2 and giving it the formula of =C12 etc to correspond to the category.

I mixed up columns with rows. My bad!
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,772
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top