|
-
Aug 22nd, 2012, 01:06 PM
#1
Thread Starter
New Member
[Excel] How do I remove a leading space
I have up to 20 6-digit numbers in one cell separated by spaces. Example 609134 60T134 60U134 373103
I'm extracting these from another in-house database and sometimes the 6 digit number is preceded by a space.
What I need to do is remove any leading or trailing spaces and ensure that the spaces between the numbers are single spaces.
After removing the leading space or spaces, I need to then copy just the first number to a cell, then the remaining to anther cell for that, I'm using:
RowCount = 2
Do While Range("J" & (RowCount)) <> ""
Range("K" & RowCount).Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[2],7)"
Range("L" & RowCount).Select
ActiveCell.FormulaR1C1 = "=RIGHT(RC[1],LEN(RC[1])-8)"
RowCount = RowCount + 1
Loop
If the cell containing all the numbers has a leading zero, I end up with the first 5 digits of the number and the cell containing the rest of the numbers starts with the last digit of the first nuimber, like so:
60913 and 4 60T134 60U134 373103
Instead of
619134 and 60T134 60U134 373103
How do I resolve this?
Thank you
Dee
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|