Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to return a number into letters? | Excel Worksheet Functions | |||
return random letters - an example | Excel Programming | |||
Return column letters to spreadsheet. | Charts and Charting in Excel | |||
VBA function to return letters of alphabet | Excel Programming |