View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Array code only works on selected sheet

Hi Howard,

Am Fri, 22 Nov 2013 21:55:09 -0800 (PST) schrieb 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.


why do you delete cell by cell?

Try:

Sub XNumOut()

Dim DeleNum As Range
Dim c As Range
Dim rngC As Range
Dim varSheets As Variant
Dim i As Long
Dim LRow As Long

varSheets = Array("Sheet2", "Sheet3", "Sheet4")

For i = LBound(varSheets) To UBound(varSheets)
With Sheets(varSheets(i))
LRow = .Cells(.Rows.Count, 1).End(xlUp).Row
Set DeleNum = .Range("A1:A" & LRow)
DeleNum.ClearContents
End With
Next

End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2