Snowshoeken
Active Member
- Joined
- Aug 8, 2002
- Messages
- 306
I cannot get my new Excel 2016 to loop through worksheets. Just runs the code the same number of times there are sheets, but not on the sheets.
Code:
Sub Don_StepALL()
'
' Macro1 Macro
'
'
Dim ws As Worksheet
For Each ws In Sheets
Range("K2").Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[-10]=""9740"",RC[-6]=""N/A""),""NON RURAL"",RC[-6])"
Selection.AutoFill Destination:=Range("K2:K65536")
Range("K2:K65536").Select
Selection.Copy
Range("E2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("K:K").Select
Application.CutCopyMode = False
Selection.ClearContents
Columns("E:E").Select
Selection.Replace What:="0", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A1").AutoFilter Field:=8, Criteria1:="<>SOFT_BROADSOFT" ', Operator:=xlAnd
Range("A2:J" & Range("J2").End(xlDown).Row).EntireRow.Delete
ActiveSheet.ShowAllData
Range("A1").AutoFilter Field:=5, Criteria1:="N/A" ', Operator:=xlAnd
Range("A2:J" & Range("J2").End(xlDown).Row).EntireRow.Delete
ActiveSheet.ShowAllData
Next ws
End Sub