Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Return the first 2 letters of a Cell Value

I have a BeforeDoubleClick_Event that I want to use to intialize different
Userforms. My users will click on certain cells that contain reference
numbers. Each number starts with two capital letters. The two letters will
dictate which Userform is Initalized. How can I extract the first two
letters of the cell value. For example:

Select Case (FIRST TWO LETTER OF TARGET)

Case PF
'code'
Case EC
'code'

End Select

Thanks in Advance,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Return the first 2 letters of a Cell Value

Is this what you are looking for...

Select Case Left$(Target.Value, 2)

Rick


"RyanH" wrote in message
...
I have a BeforeDoubleClick_Event that I want to use to intialize different
Userforms. My users will click on certain cells that contain reference
numbers. Each number starts with two capital letters. The two letters
will
dictate which Userform is Initalized. How can I extract the first two
letters of the cell value. For example:

Select Case (FIRST TWO LETTER OF TARGET)

Case PF
'code'
Case EC
'code'

End Select

Thanks in Advance,
Ryan


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Return the first 2 letters of a Cell Value

And you may want:

select case lcase(left(somecell.value,2))
case is = lcase("PF")
...
case is = lcase("EC")

You may want to do a comparison that isn't case sensitive.

I figured PF and EC were not variables--they were strings.

RyanH wrote:

I have a BeforeDoubleClick_Event that I want to use to intialize different
Userforms. My users will click on certain cells that contain reference
numbers. Each number starts with two capital letters. The two letters will
dictate which Userform is Initalized. How can I extract the first two
letters of the cell value. For example:

Select Case (FIRST TWO LETTER OF TARGET)

Case PF
'code'
Case EC
'code'

End Select

Thanks in Advance,
Ryan


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Return the first 2 letters of a Cell Value

Yes, that is what I needed! What does the $ do?

Thanks,
Ryan

"Rick Rothstein (MVP - VB)" wrote:

Is this what you are looking for...

Select Case Left$(Target.Value, 2)

Rick


"RyanH" wrote in message
...
I have a BeforeDoubleClick_Event that I want to use to intialize different
Userforms. My users will click on certain cells that contain reference
numbers. Each number starts with two capital letters. The two letters
will
dictate which Userform is Initalized. How can I extract the first two
letters of the cell value. For example:

Select Case (FIRST TWO LETTER OF TARGET)

Case PF
'code'
Case EC
'code'

End Select

Thanks in Advance,
Ryan



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Return the first 2 letters of a Cell Value

In VB/VBA, affixing a $ sign to a String function makes that function return
a pure String value; without the $ sign, String functions return Variants
with a sub-type of String. If you need a pure String value (like for your
Case tests), the pure String functions are faster executing than the Variant
ones; however, unless you are using them in a very large loop structure, the
time difference is pretty negligiable, so using it in this case does not
really aid the execution speed in any noticeable way... I use it more from
force of habit (as I come from the compiled VB world where I encountered the
large loops much more often).

Rick


"RyanH" wrote in message
...
Yes, that is what I needed! What does the $ do?

Thanks,
Ryan

"Rick Rothstein (MVP - VB)" wrote:

Is this what you are looking for...

Select Case Left$(Target.Value, 2)

Rick


"RyanH" wrote in message
...
I have a BeforeDoubleClick_Event that I want to use to intialize
different
Userforms. My users will click on certain cells that contain reference
numbers. Each number starts with two capital letters. The two letters
will
dictate which Userform is Initalized. How can I extract the first two
letters of the cell value. For example:

Select Case (FIRST TWO LETTER OF TARGET)

Case PF
'code'
Case EC
'code'

End Select

Thanks in Advance,
Ryan




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
How to return a number into letters? A.El Tohamy Excel Worksheet Functions 4 January 20th 08 01:53 PM
return random letters - an example [email protected] Excel Programming 1 August 31st 05 01:27 PM
Return column letters to spreadsheet. Isidor Charts and Charting in Excel 4 June 28th 05 03:27 PM
VBA function to return letters of alphabet SOS[_19_] Excel Programming 5 May 20th 04 07:44 PM


All times are GMT +1. The time now is 09:14 AM.

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

About Us

"It's about Microsoft Excel"