Macro to autofill from a specific row to a specific row

J

Joe M.

I need a macro to autofill formulas in row B4:K4 down stopping at B12:K12
depending upon if data exists in Cells A4 to A12. Row 13 (A13:K13) contains
totals so I do not want it to autofill past row 12. Can someone help?

Thanks in advance,
Joe M.
 
D

Dan

hi, i just posted after you, am using a macro to do much same you asked but
not sure if what you want. this should work for multiple columns where cells
have formula's (am not able to do formats to columns, without formula's in
them with this)
so three examples for paste: E: formula, F: format, P: all.. are:
(not sure if wrote this all correctly, can't see all in this little box
they give ya..)


0) make a permanent cell where ref to last row "formula" can be placed to
designate last row: (cell: C4 used in macros below, change accordingly)
=ROW($A$2000)

also make a shortcut in your menubar:
rightclick menubar, custom, page-down left macros to: web, pull copy of:
open hyperlink to menubar / right click it and rename, eg: &F
rightclick that shortcut again, assign macro, choose item from below macros..

1) copy cell or cells you want to paste
2) select top row where you to paste from
3) hit: Alt & E to use shortcut from menubar

Sub PastecellE() 'alt-E (paste cell EQ/ Formula to col)
r = ActiveCell.Row 'row
c = ActiveCell.Column 'cell
LastRow = Range("C4").Value

For Each c In Range(Cells(r, c), Cells(LastRow, c))
If Cells(c.Row, "A").Value <> "." Then
c.Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End If
Next c
End Sub


Sub PastecellF() 'alt-F (paste cell Format to col)
r = ActiveCell.Row
c = ActiveCell.Column
LastRow = Range("C4").Value

For Each c In Range(Cells(r, c), Cells(LastRow, c))
If Cells(c.Row, "A").Value <> "." Then
c.Select

Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End If
Next c
End Sub


Sub PastecellP() 'alt-P (paste cell All to col)
r = ActiveCell.Row
c = ActiveCell.Column
LastRow = Range("C4").Value

For Each c In Range(Cells(r, c), Cells(LastRow, c))
If Cells(c.Row, "A").Value <> "." Then
c.Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End If
Next c
End Sub
 
D

Dan

there.. did make a mistake: your new menubar item should be:
right click menu bar, custom, page down left side to macros, grab copy of
"custom button" / smiley face to your tool bar, right click - modify same as
prev. post, thanks
(skip hyperlink thing)
 

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