Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Removing blank characters from left of field
I am trying to import data where there is sometimes a blank in the cell
before the data - space bar. I need to get the VBA code to do something like "If left character is blank then delete left character and move ramining chaacters to the left" Tried a few different ways in VBA, but none seem to do the trick |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Removing blank characters from left of field
Hi
try application.trim "tcbootneck" wrote: I am trying to import data where there is sometimes a blank in the cell before the data - space bar. I need to get the VBA code to do something like "If left character is blank then delete left character and move ramining chaacters to the left" Tried a few different ways in VBA, but none seem to do the trick |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Removing blank characters from left of field
Use LTrim function
[destination cell] = LTrim([Source cell]) Also search in VBA help on 'Trim' and see LTrim, Trim and RTrim functions. Sharad *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Removing blank characters from left of field
Thank you, gave me a steer. The code didn't like the link to application, so
looked up trim in vba help. Code I've now come up with looks like. Sub trim_left() Dim mystring, trimstring Range("H3").Activate mystring = ActiveCell trimstring = LTrim(RTrim(mystring)) Range("i3") = trimstring End Sub with the value of ' 123456 in h3. Many thanks "tcbootneck" wrote: I am trying to import data where there is sometimes a blank in the cell before the data - space bar. I need to get the VBA code to do something like "If left character is blank then delete left character and move ramining chaacters to the left" Tried a few different ways in VBA, but none seem to do the trick |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Removing blank characters from left of field
Instead of LTrim(RTrim(mystring)) you can use simply
Trim(mystring) Sharad "tcbootneck" wrote in message ... Thank you, gave me a steer. The code didn't like the link to application, so looked up trim in vba help. Code I've now come up with looks like. Sub trim_left() Dim mystring, trimstring Range("H3").Activate mystring = ActiveCell trimstring = LTrim(RTrim(mystring)) Range("i3") = trimstring End Sub with the value of ' 123456 in h3. Many thanks "tcbootneck" wrote: I am trying to import data where there is sometimes a blank in the cell before the data - space bar. I need to get the VBA code to do something like "If left character is blank then delete left character and move ramining chaacters to the left" Tried a few different ways in VBA, but none seem to do the trick |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Removing blank characters from left of field
Thanks both for the help on this one. Never heard of trim before. Very
useful. Happy New Year "Sharad Naik" wrote: Instead of LTrim(RTrim(mystring)) you can use simply Trim(mystring) Sharad "tcbootneck" wrote in message ... Thank you, gave me a steer. The code didn't like the link to application, so looked up trim in vba help. Code I've now come up with looks like. Sub trim_left() Dim mystring, trimstring Range("H3").Activate mystring = ActiveCell trimstring = LTrim(RTrim(mystring)) Range("i3") = trimstring End Sub with the value of ' 123456 in h3. Many thanks "tcbootneck" wrote: I am trying to import data where there is sometimes a blank in the cell before the data - space bar. I need to get the VBA code to do something like "If left character is blank then delete left character and move ramining chaacters to the left" Tried a few different ways in VBA, but none seem to do the trick |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
HOW DO I EXTRACT ALL CHARACTERS AFTER 5 CHARACTERS ON LEFT | Excel Worksheet Functions | |||
removing everything from the left after 10 digits | Excel Worksheet Functions | |||
Removing blank characters ? | Excel Discussion (Misc queries) | |||
Removing characters from datetime field | Excel Discussion (Misc queries) | |||
Copying and pasting a worksheet to a blank and removing blank rows | Excel Programming |