Check for worksheets code needed

Status
Not open for further replies.

Trag

Board Regular
Joined
Dec 18, 2003
Messages
148
Hi,

Thanks for reading my post.

I've searched the board, looked through VBA Help but I don't understand how to get this to work...

I have a workbook that comes to me via email that contains 10 or less worksheets. Names and the amount of the worksheets vary. I have a macro that changes all the tab names to numbers from 1-10.

In part A of my macro, I need the macro to check to see if there is a sheet 1, if there is do what needs to be done on sheet 1. Then check to see if there is a sheet 2. If there is, do what needs to be done on sheet 2. Then check to see if there is a sheet 3. If there is, do what needs to be done on sheet 3. Etc up to ten.

If there is no page 2,3,4...10, go to part B of the macro (skipping all the things that have to be done on sheets 2,3,4...10).


My macro runs something like this...

Sub ()
Part A
Change all sheet names to numbers (1-10 depending on the amount I rec.).

Check to see if I have a Sheet 1. (don't know how to code this part)
Process Sheet 1.
Check to see if I have a Sheet 2. (don't know how to code this part either)
Process Sheet 2.
Check to see if I have a Sheet 3. (same here)
Process Sheet 3.
....
Check to see if I have a Sheet 10. (and this too)
Process Sheet 10.

Stop checking to see if there are any sheets. (Don't know how to code this part).

Part B
Other processing.

End Sub


I'd really appriciate any help. I'd appriciate the code even more if you'd be so kind.

Thank you!
~T
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Please, to help yourself get an answer you can use...

(1)
Continue this on your already-started thread http://216.92.17.166/board2/viewtopic.php?t=82054&highlight=

(2)
Show the macro that renames the sheets

(3)
Show exactly how the sheets are named (syntax, with a specific example, not just "1-10" but "One" or "1" or "Sheet1" or "Sheet 1", etc).

(4)
Explain why you are renaming them...what difference does it make what their name is?
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,606
Messages
6,120,483
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top