Auto Fill Down Macro

A

Angela T

Is there a macro that I can setup to auto fill down? For example I have an
Excel file that has numbers or text in column A rows 1, 5, 10, 17, etc. I
want to auto fill down whatever is in the cell above, only to the next
un-empty cell. So A1 auto fills down thru A2-A4 then A5 atuo fills down thru
A6-A9 and so on.
 
S

Shane Devenshire

Sorry about that last non-post.

Try this:

Sub myAutoFill()
Dim Bot As Long
With ActiveCell
Bot = .Offset(-1, 0).End(xlDown).Row - 1
.Offset(-1, 0).AutoFill _
Destination:=Range(.Offset(-1, 0).Address, Cells(Bot, .Column)), _
Type:=xlFillDefault
End With
End Sub

Assign a shortcut and make it faster.
 
F

fruitchunk

How do fix this macro it should always fill down the column regardles of the
range?

Sub autofill()
'
' autofill Macro
'

'
Range("G14").Select
ActiveCell.FormulaR1C1 = "=RC[1]+RC[2]"
Range("G14").Select
Selection.NumberFormat = "0.00"
Selection.autofill Destination:=Range("G14:G378")
Range("G14:G378").Select
End Sub
 
G

Gord Dibben

You must pick a column that will have data to last row.

Your formula "=RC[1]+RC[2]" denotes column H and I offset from column G so I
will assume column H has data.

Sub Auto_Fill()
Dim lRow As Long
With ActiveSheet
lRow = .Range("H" & Rows.Count).End(xlUp).Row
.Range("G14").FormulaR1C1 = "=RC[1]+RC[2]"
.Range("G14:G" & lRow).FillDown
End With
End Sub


Gord Dibben MS Excel MVP

How do fix this macro it should always fill down the column regardles of the
range?

Sub autofill()
'
' autofill Macro
'

'
Range("G14").Select
ActiveCell.FormulaR1C1 = "=RC[1]+RC[2]"
Range("G14").Select
Selection.NumberFormat = "0.00"
Selection.autofill Destination:=Range("G14:G378")
Range("G14:G378").Select
End Sub

Shane Devenshire said:
Sorry about that last non-post.

Try this:

Sub myAutoFill()
Dim Bot As Long
With ActiveCell
Bot = .Offset(-1, 0).End(xlDown).Row - 1
.Offset(-1, 0).AutoFill _
Destination:=Range(.Offset(-1, 0).Address, Cells(Bot, .Column)), _
Type:=xlFillDefault
End With
End Sub

Assign a shortcut and make it faster.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire
 

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