Hello, I am using the following code:
I keep getting a "Next without For" error. I suppose it's because of Worksheet_Change? If so, do I have to supply the argument in some other way or is there no way to make Worksheet_Change work like that?
Code:
Sub Sort()
ActiveWorkbook.Worksheets("FDG").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("FDG").Sort.SortFields.Add Key:=Range("B2:B911"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("FDG").Sort
.SetRange Range("A1:F911")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
For Each y In Range("A2:A1337")
If Cells(y, 3) <> "" Then
Worksheet_Change Cells(y, 3)
Else
If Cells(y, 4) <> "" Then
Worksheet_Change Cells(y, 4)
End If
Next
End Sub