ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Switching to different worksheets during a macro (https://www.excelbanter.com/excel-programming/279109-re-switching-different-worksheets-during-macro.html)

Bill Barclift

Switching to different worksheets during a macro
 
Each worksheet in your workbook belong to a worksheets collection. You can
step through each member (worksheet) of a collection without reference to
the name. See collections in the help file. Incidently, many other
collections are used by Excel as well. Having a good understanding of this
will be very beneficial.

Also, it is 'generally' better coding practice to use the select and
activate methods, judiciously. You can always create references to
workbooks, worksheets, ranges, etc., without having to select/activate them.

Bill Barclift

"Michelle72" wrote in message
...
I have a workbook with 10 worksheets in it. The first sheet is a data
entry page and upon filling in all necessary cells, I click on a button
for a macro I have created that runs a series of macros on all sheets.
This macro consists of several other macros...for example, it selects
the next sheet and performs a macro then selects the next sheet and
performs a macro and so on until it has run each macro on the 9
sheets(one on each sheet). Currently, in the large macro on the 1st
sheet it selects the next sheet as follows:

Sheets("name of sheet").Select

Is there anyway to tell it to select the next worksheet without having
to actually have the name of the sheet in there? In the future, I will
be adding and deleting worksheets as my customer base changes and it
would be great to have a "generic select the next sheet until there
aren't anymore code" and it would allow me to not have to edit my
macro(s) everytime that happens

Any help would be greatly appreciated!

Thanks,
Michelle :)



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/





All times are GMT +1. The time now is 06:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com