JohnZ1156
Board Regular
- Joined
- Apr 10, 2021
- Messages
- 160
- Office Version
- 2021
- Platform
- Windows
I have a table of numbers with many rows. (1918 rows)
Column A has a date, numbers are from columns B:F
If cell A2 has a date, I would like to sort B2:F2 independently.
Then look down into the next row.
If cell A3 has a date, I would like to sort B3:F3 independently.
And so on until the macro doesn't see a date in column A.
I recorded a Macro which will only do one row at a time.
Column A has a date, numbers are from columns B:F
If cell A2 has a date, I would like to sort B2:F2 independently.
Then look down into the next row.
If cell A3 has a date, I would like to sort B3:F3 independently.
And so on until the macro doesn't see a date in column A.
I recorded a Macro which will only do one row at a time.
VBA Code:
Sub Macro1()
'
' Macro1 Macro
'
Range("B2:F2").Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add2 Key:=Range("B2:F2") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("B2:F2")
.Header = xlGuess
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
End Sub