|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm required to display range names beginning with the 3 letters "Reg", using the UCase function and the Like operator. Why doesn't my Excel macro work as follows? Thank you.
Public Sub Display() Dim intMessage As Integer, r As Integer, nms As Object Set nms = ActiveWorkbook.Names For r = 1 To nms.Count If UCase(nms(r)) Like UCase("Reg *") Then intMessage = MsgBox("Range name " & r & ": " & nms(r).Name) End If Next End Sub |
|
#2
|
||||
|
||||
|
what's wrong with simple comparison??
Code:
If UCase(Left(nms(r), Len("REG")))="REG" Then
|
|
#3
|
|||
|
|||
|
Thank you for your responce, but, unfortunately my msgBox is still not appearing, and I'm supposed to use the 'Like' operator.
|
|
#4
|
||||
|
||||
|
I'm not familiar with the LIKE command, so I tried to use something
I do know. you get error? if not, debug may help: Code:
MsgBox("value: " & nms(r))
what you see in the message? |
|
#5
|
|||
|
|||
|
I found the answer. Problem solved. Thanks.
|
|
#6
|
||||
|
||||
|
can you please share it for others who might have the same problem?
![]() |
|
#7
|
|||
|
|||
|
I'm sorry. Yes Shadow, of course. Here it is:
Dim nsm As Name 'Display only range names that start with "Reg" For Each nms In Names If UCase(nms.Name) Like UCase("Reg*") Then intMessage = MsgBox("Range name: " & nms.Name) End If Next |
|
#8
|
||||
|
||||
|
so the problem was the blank space after "Reg".. ?
|
|
#9
|
|||
|
|||
|
Solution
Well, I tried it without the space before and it didn't help. Then I was told that I needed to use a "For each" instead of the "For" clause. I don't know why. Then I was to dim nsm as Name, not an object. That part makes sense. Did you see my new post about the Word macro I'm having trouble with? I need code that would place the insertion point in the last row of a table.
|
|
#10
|
|||
|
|||
|
I tried to add to your rep for your effort, but there's only a zero in the drop-down box. So, I tried to send a private message to let you know, but that was disabled. Then I checked out the knowledgebase and troubleshooting links for answers: I don't have Norton, I turned down my security settings. Those suggestions didn't work. Then, I tried to submit an email to the support link. That was disabled. I verified that I'm logged on, and my new account has been activated. This is strange!
|
|
#11
|
||||
|
||||
|
Hey Donald, right now u have only 0 rep power, so u can give only 0 rep points to anyone. Regarding Private message, try again........ u must have tried it when ur post count were less than 10......... now u have 12 posts, so u can send Private message now.
|
|
#12
|
||||
|
||||
|
Quote:
some things in there. glad you could find the solution! ![]() as for your new thread I really have no idea, sorry. regarding the restrictions, they were put into place to protect our forum from spammers - until you have 30 posts and member for 30 days you're not considered full member thus have many restrictions on your account. you can blame the spammers for this, and if you stick around you'll become full member shortly. ![]() |
![]() |
| Viewing: ASP Free Forums > Other > Programming Help > VB for Apps - Comparison Operator Issue |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread < |