Maintain the contents of a specific cell, even after a sort

slam

Well-known Member
Joined
Sep 16, 2002
Messages
921
Office Version
  1. 365
  2. 2019
I have a spreadsheet of race results. There is a total points column, then adjacent, there is a gap column. The contents of the gap column row by row is as follows:

-
=$X$3-X4
=$X$3-X5

And so on.

How do I exclude this one Gap column from the sort (even though there are columns to be included as part of the sort range at either side), or how do I have them maintain the same cell references after the sort, including the dash (-) in the first row?

Thanks
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You could move it to the left or right of the sort area.
 
Upvote 0
You could move it to the left or right of the sort area.

It is only relevant to the adjacent column unfortunately, and it would be confusing and irrelevant elsewhere.
 
Upvote 0
How about this.....

I currently automatically sort the worksheet with this code:


Private Sub Worksheet_Activate()
Range("B3:AC18").Sort Key1:=Range("X3"), Order1:=xlDescending, _
Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub


Would it be possible to modify this to also re-apply the dash (in Y3) and the formula in (Y4 through Y18) as follows:


-
=X$3-X4
=X$3-X5
=X$3-X6
=X$3-X7
=X$3-X8
=X$3-X9
=X$3-X10
=X$3-X11
=X$3-X12
=X$3-X13
=X$3-X14
=X$3-X15
=X$3-X16
=X$3-X17
=X$3-X18
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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