H
Howard
The code in a standard module and a list of numbers in sheet 1, column A.
I run the code and it only works on whatever sheet is selected.
If the sheet is sheet 1 then it eliminates my list in column A.
If sheet 2 is selected and I run the code it works for that sheet on the scattered test numbers, and that sheet alone.
What is stopping the code from going to sheet 2, then 3 then 4 as I would think it should, given the array elements?
Thanks,
Howard
Option Explicit
Sub XNumOut()
Dim DeleNum As Range
Dim c As Range
Dim rngC As Range
Dim varSheets As Variant
Dim DelC As Range
Dim i As Long
Dim Lrow As Long
Lrow = Range("A" & Rows.Count).End(xlUp).Row
Set DeleNum = Sheets("Sheet1").Range("A1:A" & Lrow)
varSheets = Array("Sheet2", "Sheet3", "Sheet4")
For i = LBound(varSheets) To UBound(varSheets)
With Sheets(varSheets(i))
For Each c In DeleNum
Cells.Replace What:=c, Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Next
End With
Next
End Sub
I run the code and it only works on whatever sheet is selected.
If the sheet is sheet 1 then it eliminates my list in column A.
If sheet 2 is selected and I run the code it works for that sheet on the scattered test numbers, and that sheet alone.
What is stopping the code from going to sheet 2, then 3 then 4 as I would think it should, given the array elements?
Thanks,
Howard
Option Explicit
Sub XNumOut()
Dim DeleNum As Range
Dim c As Range
Dim rngC As Range
Dim varSheets As Variant
Dim DelC As Range
Dim i As Long
Dim Lrow As Long
Lrow = Range("A" & Rows.Count).End(xlUp).Row
Set DeleNum = Sheets("Sheet1").Range("A1:A" & Lrow)
varSheets = Array("Sheet2", "Sheet3", "Sheet4")
For i = LBound(varSheets) To UBound(varSheets)
With Sheets(varSheets(i))
For Each c In DeleNum
Cells.Replace What:=c, Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Next
End With
Next
End Sub