space in begining of cell

l0rtsu

New Member
Joined
Apr 18, 2002
Messages
3
First of all, I know that there are already topic of same problem but I couldnt find help from it and I am really newbie in VBA, I started "programmin" with this today.

I am doing small excel "database" which has three columns and I dont want to remove manually spaces for begining of every cell in two of the rows. Information comes from web-site so cant remove spaces from that way. I am using Office Xp so Excel is 2002. What sorta macro should I use?

btw, I cannot use Trim-function since those cells must be formated as "text" because otherwise zeros wouldnt stay in phone column.

Mika
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
btw, I cannot use Trim-function since those cells must be formated as "text" because otherwise zeros wouldnt stay in phone column.

Mika

You lost me... =TRIM(" 006") produces "006".

Also, knowing that your data is sourced from a web page keep in mind that what looks like spaces may be a non-printable ASCII value instead.
This message was edited by Mark W. on 2002-04-19 16:14
 
Upvote 0
You lost me... =TRIM(" 006") produces "006".
This message was edited by Mark W. on 2002-04-19 16:14
No it doesnt (at least for me...:)) if cell is formated to "text". I just tested it, if cell type is "text" and you put '=TRIM( 123123)' it stays that way but if you change cell type example to "general" it changes to "123123"
This message was edited by l0rtsu on 2002-04-19 16:31
 
Upvote 0
On 2002-04-19 16:30, l0rtsu wrote:
You lost me... =TRIM(" 006") produces "006".
This message was edited by Mark W. on 2002-04-19 16:14
No it doesnt (at least for me...:)) if cell is formated to "text". I just tested it, if cell type is "text" and you put '=TRIM( 123123)' it stays that way but if you change cell type example to "general" it changes to "123123"
This message was edited by l0rtsu on 2002-04-19 16:31

Hi Mika:
What you are saying is not clear. Trim function is used to clear the extra space from a TEXT string.
Chances are if TRIM function is not removing the extra spaces, then as Mark stated above, it may be a non-printable character (and not necessarily a space) that you are not able to remove.
Please post a sample of the entry from where you are trying to remove a character or a non-character as the case may be.
 
Upvote 0
Thanks for replying so fast and it is space, Code returned 32. I also checked it by turning one cell to general type and =trim(A5) parsed it correctly. And I cannot turn them all to General because then phone numbers wouldnt be listed correctly.
 
Upvote 0
On 2002-04-19 16:59, l0rtsu wrote:
Thanks for replying so fast and it is space, Code returned 32. I also checked it by turning one cell to general type and =trim(A5) parsed it correctly. And I cannot turn them all to General because then phone numbers wouldnt be listed correctly.

Are you saying you have 1 or more 0s in the beginning of the entry, and you are losing those 0s after you TRIM the original string -- I don't see why that has to be so, but in any event you can then reformat it as Text using

=TEXT(A1,"0000000") adjusting the number of 0s to suit

Please post back if it helps ... otherwise explain a little further and let us take it from there!
 
Upvote 0
On 2002-04-19 16:59, l0rtsu wrote:
Thanks for replying so fast and it is space, Code returned 32. I also checked it by turning one cell to general type and =trim(A5) parsed it correctly. And I cannot turn them all to General because then phone numbers wouldnt be listed correctly.

Just select your cells containing phone numbers formatted as text, choose the Edit | Text to Columns... menu command, and follow these steps...

1. At Step 1 of 3 of the wizard, choose the "Fixed width" data type and press [ Next> ]
2. At Step 2 of 3 click in the data preview window on the 1st unit of the ruler and press [ Next> ]
3. At Step 3 of 3 format the 1st (single character) column as "Do not import column (Skip)". Select the 2nd column (containing your phone number) and format as "Text". Press [ Finish ].
 
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,676
Members
448,977
Latest member
moonlight6

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top