Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write Left Function in VB
Hi. I'm trying to programmatically write this line of code into a
macro: =LEFT(A1,FIND("-",A1)-1) The function shows all characters to the left of a hyphen. Anything to the right and the hypen isn't displayed. Ex. 12345-6789 shows as 12345 I'd like to use this function in code to highlight an entire column like A:A and display the results in B:B. I'd also like to ignore rows where no hyphen is found. Can anyone help on this? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write Left Function in VB
I'm trying to programmatically write this line of code into a
macro: =LEFT(A1,FIND("-",A1)-1) The function shows all characters to the left of a hyphen. Anything to the right and the hypen isn't displayed. Ex. 12345-6789 shows as 12345 I'd like to use this function in code to highlight an entire column like A:A and display the results in B:B. I'd also like to ignore rows where no hyphen is found. Can anyone help on this? I would not use the LEFT function at all; the following will be much quicker... Sub GetTextBeforeHyphen() Columns("B").Value = Columns("A").Value Columns("B").Replace "-*", "", xlPart End Sub Rick Rothstein (MVP - Excel) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write Left Function in VB
On Sep 22, 3:09*pm, "Rick Rothstein"
wrote: I'm trying to programmatically write this line of code into a macro: =LEFT(A1,FIND("-",A1)-1) The function shows all characters to the left of a hyphen. *Anything to the right and the hypen isn't displayed. Ex. *12345-6789 shows as 12345 I'd like to use this function in code to highlight an entire column like A:A and display the results in B:B. I'd also like to ignore rows where no hyphen is found. *Can anyone help on this? I would not use the LEFT function at all; the following will be much quicker... Sub GetTextBeforeHyphen() * * Columns("B").Value = Columns("A").Value * * Columns("B").Replace "-*", "", xlPart End Sub Rick Rothstein (MVP - Excel) Thanks! I didn't imagine that to be so simple. How do I get this to work even if certain rows are hidden with a filter? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to nest a left function within a sumif function? | Excel Worksheet Functions | |||
LEFT function-all to left of a comma? | Excel Worksheet Functions | |||
Over write a file someone has left opened. | Excel Programming | |||
Left vs Left$ function | Excel Discussion (Misc queries) | |||
HOW DO I NEST THE VLOOKUP FUNCTION WITH THE LEFT FUNCTION | Excel Worksheet Functions |