Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW DO I EXTRACT ALL CHARACTERS AFTER 5 CHARACTERS ON LEFT GRYSYF Excel Worksheet Functions 5 October 12th 05 10:58 AM
removing everything from the left after 10 digits tri_p Excel Worksheet Functions 3 September 30th 05 12:33 PM
Removing blank characters ? bvinternet Excel Discussion (Misc queries) 2 July 24th 05 09:15 AM
Removing characters from datetime field Sujesh Excel Discussion (Misc queries) 3 July 14th 05 03:22 PM
Copying and pasting a worksheet to a blank and removing blank rows Bob Reynolds[_3_] Excel Programming 0 June 24th 04 02:55 PM


All times are GMT +1. The time now is 11:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"