Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can you tell me why mine didn't work?
When you used the Set key word, you created an OBJECT varable. You then tried to compare the object to a property (text string) name. That wont work. Object variables apply to Object items like Workbook, Sheet, Range, etc. Regular variables apply to properties like text, values, fonts, etc. When making comparisons, be sure they are the same data type and class. Exmpl: If wsShtToSave = Sheets('Master") 'compares objects or If wsShtToSave.Name = "Master" 'compares properties Either of the above would work. "oldjay" wrote in message ... Thank I will use your code. Can you tell me why mine didn't work? "Mike H" wrote: Hi, Why not make it simpler If ActiveSheet.Name = "Master" Then ActiveWorkbook.Save ActiveWorkbook.Close End If Mike "oldjay" wrote: Why won't this work? oldjayo Sub test() Dim wsShtToSave As Worksheet Set wsShtToSave = ActiveSheet If wsShtToSave= "Master" Then ActiveWorkbook.Save ActiveWorkbook.Close End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Ecape key to close/exit sheet | Excel Programming | |||
how to use Application.VLookup on close sheet | Excel Programming | |||
Vlookup from close sheet via VBA | Excel Programming | |||
Before close - not always deleting sheet- WHY?? | Excel Programming | |||
Hanging on sheet close | Excel Programming |