View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Copying first 4 characters of column

maybe something like this, just change the references to your needs

Option Explicit
Sub move_data()
Dim lastrow As Long
Dim cell As Range
Dim i As Integer
i = 1
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "A") _
..End(xlUp).Row
With Worksheets("Sheet2")
For Each cell In Range("A1:A" & lastrow)
..Range("A" & i).Value = Left(cell, 4)
i = i + 1
Next
End With
End Sub


--


Gary


"reena" wrote in message
...

I want to write a macro for copying first number of letters of a value
of the cell.
for eg.
My column contains values as

abcdefghijklmnop
xyzsgfht
reenap
pppppppppppp


Now here I want to select only "abcd" - first 4 characters of the
entire column and copy it in other excel sheet. New sheet should
contain

abcd
xyzs
reen
pppp

as column.

How can I do that?


--
reena
------------------------------------------------------------------------
reena's Profile:
http://www.excelforum.com/member.php...o&userid=30440
View this thread: http://www.excelforum.com/showthread...hreadid=506265