S
Souny
Hello all,
I have 3 defined names (Sheet1!DefineName1, Sheet1!DefineName2 and 'Sheet
2'!DefineName3) in two worksheets of my Excel file.
I need help with writing a code to execute if one of the 3 above defined
names is not in the workbook, message the users that please use another
template. Else execute the rest of code.
Below is the code that I currently have, and it's not working.
if activeworkbook.name<>"DefineName1" or activeworkbook.name<>"DefineName2"
or activeworkbook.name<>"'Sheet 2'!DefineName3" then
msgbox "Please use another template.",vbinformation
else
execute the rest of code
end if
Based on the above code, even if I have all three define names in the
workbook, the message comes up and it does not execute the rest of code. The
message should not come up and the code should execute the rest of code if
all three define names are in the workbook.
Thanks.
I have 3 defined names (Sheet1!DefineName1, Sheet1!DefineName2 and 'Sheet
2'!DefineName3) in two worksheets of my Excel file.
I need help with writing a code to execute if one of the 3 above defined
names is not in the workbook, message the users that please use another
template. Else execute the rest of code.
Below is the code that I currently have, and it's not working.
if activeworkbook.name<>"DefineName1" or activeworkbook.name<>"DefineName2"
or activeworkbook.name<>"'Sheet 2'!DefineName3" then
msgbox "Please use another template.",vbinformation
else
execute the rest of code
end if
Based on the above code, even if I have all three define names in the
workbook, the message comes up and it does not execute the rest of code. The
message should not come up and the code should execute the rest of code if
all three define names are in the workbook.
Thanks.