Thread
:
Need Help on Define Names
View Single Post
#
8
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
Need Help on Define Names
If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You send a clear explanation of what you want
3. You send before/after examples and expected results.
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Souny" wrote in message
...
Don,
Thank you very much for the code. I tried your code, and somehow, I am
still getting the message even if I have all 3 define names.
I don't know the following information would relevant to the code that I
need help with.
I have more than these 3 defined names in my workbook. I want the code to
message the users if these 3 defined names specifically do not exist in
the
workbook. If these 3 defined names specifically exist in the workbook,
the
rest of code would execute.
Below is a sample to indicate the structure that I currently have.
Sub checknames()
mc = 0
For Each n In ThisWorkbook.Names
If LCase(Left(n.Name, 4)) = "name" Then
mc = mc + 1
If mc = 3 Then Exit For
End If
Next n
If mc < 3 Then
MsgBox "another"
else
'execute the rest of code
End Sub
Thanks.
"Don Guillett" wrote:
Sub checknames()
mc = 0
For Each n In ThisWorkbook.Names
If LCase(Left(n.Name, 4)) = "name" Then
mc = mc + 1
If mc = 3 Then Exit For
End If
Next n
'If mc = 3 Then MsgBox "oK"
If mc < 3 Then MsgBox "another"
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Souny" wrote in message
...
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.
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett