View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dove Dove is offline
external usenet poster
 
Posts: 25
Default Code to look at all sheets not just specified sheet ?

Corey,

Add the following (wrapping around your code with 3 changes) and it should
work:

Dim i as Integer

mybook.Activate
For i = 2 to Sheets.Count

' Put the code you have below here, replacing the "Worksheets(4)" with
"Sheets(i)" in all 3 instances

Next i

I don't know of a way to do all at once, only to step through each sheet one
at a time...

David

How can i change the [Worksheets(4)] in (2)two instances below to refer to
ALL(could be anywhere from 2-49) sheets in the workbooks instead ?


If mybook.Worksheets(4).Range("B3").Value = input1 And
mybook.Worksheets(4).Range("D3").Value = input2 Then
mybook.Worksheets(4).Copy
After:=basebook.Sheets(basebook.Sheets.Count)

The 3rd instance of Worksheets(4)[Worksheets(4).Copy] needs to be the
sheet that contains the 2 range values (B3" & "D3"),
where the other 2 instances [worksheets(4)] need to refer to ALL sheets in
the workbook.



Regards

Corey....