Excel Macro
#1
Excel Macro
Hi
I have the following in an excel spreadsheet which sorts a range of cells I have but after its sorted the cells it highlights all the cells and leaves me in the last cell, I can't move anywhere, what can i do to change this.
I Have:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("B26:J35").Select
Range("J35").Activate
Selection.Sort Key1:=Range("J26"), Order1:=xlDescending
End Sub
Any help is appreciated.
I have the following in an excel spreadsheet which sorts a range of cells I have but after its sorted the cells it highlights all the cells and leaves me in the last cell, I can't move anywhere, what can i do to change this.
I Have:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("B26:J35").Select
Range("J35").Activate
Selection.Sort Key1:=Range("J26"), Order1:=xlDescending
End Sub
Any help is appreciated.
#4
Looks like it's getting stuck in a loop.
Worksheet_SelectionChange will run everytime the cell changes.
I would expect you need the macro to run everytime you update the worksheet rather than move between cells?
If so this should work:
Private Sub Worksheet_Change(ByVal Target As Range)
Range("B26:J35").Select
Range("J35").Activate
Selection.Sort Key1:=Range("J26"), Order1:=xlDescending
End Sub
Delete the old macro or that will take priority.
Worksheet_SelectionChange will run everytime the cell changes.
I would expect you need the macro to run everytime you update the worksheet rather than move between cells?
If so this should work:
Private Sub Worksheet_Change(ByVal Target As Range)
Range("B26:J35").Select
Range("J35").Activate
Selection.Sort Key1:=Range("J26"), Order1:=xlDescending
End Sub
Delete the old macro or that will take priority.
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
bluebullet29
General Technical
9
05 October 2015 02:17 PM