Copy column data

  • Thread starter Thread starter Sylvia
  • Start date Start date
S

Sylvia

Hi,

I want to write a macro by whic I will mention the number of character
in one column then it should select only those number of characters fo
the entire row.

eg. if I mention number of characters as 6 for 'column a', (I wil
mention this in a seperate column. Macro should read this value fro
that column) then it should copy only 6 characters of EACH cell i
'column a'

Do we anything kind of format etc for this thing?

Thanks,
Sylvi
 
Sub Tester()
Dim s As Worksheet
Dim s2 As Worksheet
Dim r As Long, x

Set s = ActiveSheet
Set s2 = ThisWorkbook.Sheets("Sheet2")

r = 1
x = Application.InputBox("Enter number of characters", _
, , , , , , 1)

Do While s.Cells(r, 1).Value <> ""
s2.Cells(r, 1).Value = Left(s.Cells(r, 1).Value, x)
r = r + 1
Loop
End Sub

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top