View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Elaine[_5_] Elaine[_5_] is offline
external usenet poster
 
Posts: 2
Default Trim or Len help (I think)

Thank you so much. That was exactly what I was looking for.

Elaine


"RB Smissaert" wrote in message
...
If you adjust this to your particular situation it will do the job.
Using an array will make it faster than looping through the cells.

Sub test()

Dim i As Long
Dim NameIDArray()

NameIDArray = Range(Cells(1), Cells(20, 2))

For i = 1 To 20
NameIDArray(i, 1) = Left(NameIDArray(i, 1), 4)
NameIDArray(i, 2) = Right(NameIDArray(i, 2), 4)
Next

Range(Cells(1), Cells(20, 2)) = NameIDArray

End Sub


RBS







"Elaine" wrote in message
...
In my worksheet I have two columns.

Column A contains (LAST name, FIRST name)
Column B contains (an ID number.)

I would like to change Column A to contain only the FIRST 4 letters of

the
last name
I would like to change Column B to contain only the LAST 4 numbers of

the
ID
number

I have had some experience using Word VBA, but not that much in Excel.

I
do
want to do this using VBA because there are other steps that I need to

take
also. I'd appreciate any help that I can get on this.

Elaine