Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using If Then to check for a worksheet
I am creating an add-in for work. When the user opens the Add-in I
want to have code that checks to make sure a specific sheet exists in the workbook before the addin works. Something to the effect of If activeWorkbook contains "Sheet1" Then Copy "addin" else MsgBox "You have the wrong spreadsheet opened" Can someone help me work out the code? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using If Then to check for a worksheet
Dim wks as worksheet
set wks = nothing on error resume next set wks = activeworkbook.worksheets("doesitexist") on error goto 0 if wks is nothing then 'it ain't there 'do something else 'yep, it's there 'keep going end if ========= Although, I would think that this kind of thing would be better for each routine in your addin--instead of checking just the activeworkbook when the addin opens. stewdizzle wrote: I am creating an add-in for work. When the user opens the Add-in I want to have code that checks to make sure a specific sheet exists in the workbook before the addin works. Something to the effect of If activeWorkbook contains "Sheet1" Then Copy "addin" else MsgBox "You have the wrong spreadsheet opened" Can someone help me work out the code? -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I copy a check box result from Worksheet A to Worksheet B? | Excel Worksheet Functions | |||
Check if worksheet is before another | Excel Discussion (Misc queries) | |||
check if worksheet is empty | Excel Programming | |||
check if worksheet exists | Excel Programming | |||
How to check if a worksheet exists in worksheet collection | Excel Programming |