ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Ignore Missing Worksheets (https://www.excelbanter.com/excel-programming/399687-ignore-missing-worksheets.html)

Jim

Ignore Missing Worksheets
 
Hello - I've created a workbook that functions as a purchase order. It allows
a user to select anywhere from 1 to 12 styles for their purchase order - the
macro creates that number of worksheets based on what the user selects.

The worksheets created have no formulas in them. I have a "master" sheet
that does contain the formulas but to put formulas in each of the sheets as
they're created would take too long to calculate.

Is there a way to create a macro that basically says "If Style 1 exists,
paste the formulas from the Master worksheet. If Style 2 exists, paste the
formulas from the Master worksheet. - etc... I tried creating a macro that
pastes the formulas for the maximum number of styles (12), but I get errors
when the worksheet doesn't exist (of course).

Thank you for whatever help you can give me.

excel-ant

Ignore Missing Worksheets
 
Hiya,

Use Error handling to skip over where your sheets don't exist.
On Error Resume Next switches the error handling off
On Error Goto 0 switches it back on

----------------------------------------------------
Sub HandleSheets()

On Error Resume Next
Sheets("NotThere").Select
On Error GoTo 0

End Sub
------------------------------------------------------
http://www.excel-ant.co.uk


Nigel[_2_]

Ignore Missing Worksheets
 
Maybe too big an overhead, but in view of your time and create issues, why
not have ALL sheets pre-existing (maybe use a template?) all versions
initially very hidden and then unhide those the user chooses?

--

Regards,
Nigel




"Jim" wrote in message
...
Hello - I've created a workbook that functions as a purchase order. It
allows
a user to select anywhere from 1 to 12 styles for their purchase order -
the
macro creates that number of worksheets based on what the user selects.

The worksheets created have no formulas in them. I have a "master" sheet
that does contain the formulas but to put formulas in each of the sheets
as
they're created would take too long to calculate.

Is there a way to create a macro that basically says "If Style 1 exists,
paste the formulas from the Master worksheet. If Style 2 exists, paste
the
formulas from the Master worksheet. - etc... I tried creating a macro
that
pastes the formulas for the maximum number of styles (12), but I get
errors
when the worksheet doesn't exist (of course).

Thank you for whatever help you can give me.




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

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