View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Sharad Naik Sharad Naik is offline
external usenet poster
 
Posts: 212
Default 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