Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default .Name case sensitive

As part of a Print Macro, I am populating a list box with all range names
beginning with "prt1". In testing my macro, I noted that it was case
sensitive ("prt1 vs Prt1"). I've handled this with an OR statement. I'd
like a more robust solution which handles all the possible upper/lower case
combinations of prt1. Thanks in advance!

Here is my code:

Private Sub UserForm_Initialize()
Dim nme As Name

With lstP1
For Each nme In ActiveWorkbook.Names
If Left(nme.Name, 4) = "Prt1" Or Left(nme.Name, 4) = "prt1" Then
.AddItem nme.Name
End If
Next nme
End With

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default .Name case sensitive

CinqueTerra wrote:
As part of a Print Macro, I am populating a list box with all range names
beginning with "prt1". In testing my macro, I noted that it was case
sensitive ("prt1 vs Prt1"). I've handled this with an OR statement. I'd
like a more robust solution which handles all the possible upper/lower case
combinations of prt1. Thanks in advance!

Here is my code:

Private Sub UserForm_Initialize()
Dim nme As Name

With lstP1
For Each nme In ActiveWorkbook.Names
If Left(nme.Name, 4) = "Prt1" Or Left(nme.Name, 4) = "prt1" Then
.AddItem nme.Name
End If
Next nme
End With



How about:

If ucase(Left(nme.Name, 4)) = "PRT1" Then

Bill
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default .Name case sensitive

Another option is to put:

Option Compare Text

At the top of the module.

If you have lots of code with lots of comparisons (and case really shouldn't
matter), it might be the easiest fix.



CinqueTerra wrote:

As part of a Print Macro, I am populating a list box with all range names
beginning with "prt1". In testing my macro, I noted that it was case
sensitive ("prt1 vs Prt1"). I've handled this with an OR statement. I'd
like a more robust solution which handles all the possible upper/lower case
combinations of prt1. Thanks in advance!

Here is my code:

Private Sub UserForm_Initialize()
Dim nme As Name

With lstP1
For Each nme In ActiveWorkbook.Names
If Left(nme.Name, 4) = "Prt1" Or Left(nme.Name, 4) = "prt1" Then
.AddItem nme.Name
End If
Next nme
End With


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
countif function: how to distinguish case/make case sensitive mvwoolner Excel Worksheet Functions 3 March 18th 09 02:18 PM
How do I use case sensitive VLOOKUP? markythesk8erboi Excel Worksheet Functions 8 June 4th 08 04:44 PM
Case Sensitive w/ IF jeffP Excel Worksheet Functions 11 February 6th 06 01:16 AM
Case sensitive vlookup Tawe Excel Discussion (Misc queries) 3 June 13th 05 03:43 PM
UDF - case sensitive argument ed Excel Programming 2 January 21st 05 04:55 PM


All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"