View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Iterating Through Workbook if Don't Know Sheet Names

You can refer to sheets with an index rather than a name:

Sub sht()
nsh = Sheets.Count
For n = 1 To nsh
MsgBox (Sheets(n).Name)
Next
End Sub

--
Gary''s Student - gsnu200729


"wrldruler" wrote:

I've got an Access database that produces an "Active Project" report.
It creates a new worksheet tab for every project we have running in
our office. I chose to give the worksheet the same name as the
project, thus allowing for easy browsing when a user opens the Excel.

Now I want to create a macro that copies the worksheet over to a
PowerPoint slide. I am using this line of code:

Worksheets("Test_Project").Range("B1:P28").CopyPic ture
Appearance:=xlPrinter, Format:=xlPicture

But notice I had to hard code "Test_Project" as the Worksheet name. I
don't want to hard code the name because our project list is always
changing.

I could use "ActiveSheet.Name", but then I would have to run the macro
on every worksheet.

Is there a way I can tell Excel to select the first worksheet
(whatever that may be called) and then go on to the second, and third
-- ignoring the tab names and caring only about the tab position?

Thanks,

Chris