Macro that will autofill a column with data, up to the last row of data in previous c

M

Max Velocity

Hi everyone,

I beleive this is a relatively simple question, but it is frustratin
me a lot. I would like to use the simplest possible macro to fill
number of specified columns with data. I always know which row the dat
should begin in. I would like to feed off another column in the sam
sheet for my range, but data in this column fluctuates. Should I use a
IfEmpty function...? If so how would you write it?

Cheers!

Ma
 
R

Ron de Bruin

Try this

Will FillDown b1:d1 till the last row with data in column A

Sub test()
Dim a As Long
a = Range("A" & Rows.Count).End(xlUp).Row
Range("B1:D" & a).FillDown
End Sub
 
M

Max Velocity

Okay so lets say that I have formulas in Cells: B2,C2,D2,E2
And at the end of my macro I want to have the contents of the abov
four cells filled down all the way to where the data ends in column A


How does this work? Do I have to repeat all the formulas? Forgive m
i'm a VBA beginner.

Cheers,

Lysande
 
R

Ron de Bruin

Use this example

Lrow = Range("A" & Rows.Count).End(xlUp).Row
This line will give you the row number of the last cell with data in Column A

Range("B2:E" & a).FillDown
This line will FillDown the cells B2:E2 to the row Lrow

Sub test2()
Dim Lrow As Long
Lrow = Range("A" & Rows.Count).End(xlUp).Row
Range("B2:E" & Lrow).FillDown
End Sub
 
M

Max Velocity

Thanks Ron its Perfect. Although it appears that It cannot be used mor
than once in a 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