Record Macro in Excel, run macro untill last column

O

Oamya Kim

Hi,
I want to record macro to perform some functions (e.g., simple funtion as
below).
I'd like to hv result shown in column B according to input data from col A,
but the below macro only run up to certain number of rows (here is 4 rows)
only.

How about If I input data at column A up to 100 rows, or sometimes 5000 rows,

Pls anyone help me, which additional VBA code i should add ii order to run
the macro up to numbers of rows at each time.

col A col B
Items Test
BHAKSJDDKF =left(A2,5)
BHEKJFKJG
BHM5FGF
BHPKRG


Sub AddPrefix()

Range("B2").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[-1],5)"
Range("B2:B5").Select
Selection.FillDown
End Sub

Pls. help. Thanks a lot
 
W

Wigi

Sub AddPrefix()

Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row).Formula =
"=LEFT(RC[-1],5)"
End Sub
 

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

Top