Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code For Text To Columns

Status
Not open for further replies.

APElliott

Technical User
Jul 9, 2002
165
GB
Hello,

I'm trying to automate a Text to Column routine, but can quiet manage.

The trouble is as follows.

The column in question is B and generally the text is a number followed by a letter ie 1A, 2A, 10A, and I want the number to remain in B and the letter to go to C.

If I do it manually it take a couple of goes.

Thanks

Andrew [afro]
 
Drew,

If it is ALWAYS some numeric string followed by A SINGLE ALPHA CHARACTER, then assuming that the column is A

the numeric part in col b...
Code:
=left(A1,len(A1)-1)
the alpha part in col c...
Code:
=right(A1,1)
:)

Skip,
Skip@TheOfficeExperts.com
 
or if you want to write code, select the range...
Code:
for each c in selection
  with c
    .value = left(.value, len(.value) -1)
    .offset(0, 1).value = right(.value, 1)
  end with
next
The spreadsheet process makes 2 new columns of data.

the VBA makes 1 new column of data.

:)


Skip,
Skip@TheOfficeExperts.com
 
Hi Skip,

I've tried running it on col G as below, but it saying invalid procedure?

lRow = Cells(65536, 1).End(xlUp).Row
Range("g2:g" & lRow).Select
For Each c In Selection
With c
.Value = Left(.Value, Len(.Value) - 1)
.Offset(0, 1).Value = Right(.Value, 1)
End With
Next


Thanks

Andrew [afro]
 
Hi Skip,

I've ran the code, but its losing the alpha part.

Also I had to fill in a few blank cells, how would I get it to go past blank cells,

Cheers,

Andrew [afro]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top