![]() |
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 |
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 |
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! |
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 |
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 |
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 |
All times are GMT +1. The time now is 01:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com