R
revinfo
I so seldom have to edit my macros anymore, since most have worked now
for several years with little trouble. However, the macro below fills
in blank cells that have a different number of rows each month. Until
this month, Range commands all began at A11, which worked fine until I
had to insert three rows above it. I didn't think of the impact and of
course the macro referencing cells in row 11 caused this macro to
really make quite a mess.
Below, there are different sets of copy opearations that take place
based on certain colums, and that shouldn't change. However for
anything below that now references row 14, how can I defend the
integrity of the macro if I need to insert or delete rows in the
future? There is no range name defined right now that begins on row
14, but there is a row 11 range name called START, if you wanted to
offset it that way like I did it on the 3rd line of the macro below. I
appreciate the help. I just do these every day anymore to remember all
the tricks available.
Bruce
Sub Fillinblanks()
Dim cRows As Long
cRows = Cells(14, 7).End(xlDown).Row
Range("Start").Offset(3, 0).Select
Range(ActiveCell, ActiveCell.Offset(0, 5)).Select
Range("a14:F14").AutoFill Destination:=Range("A14:F14", Cells(cRows,
"A"))
Range("A14:F14", Cells(cRows, "A")).Copy
Range("A14:F14", Cells(cRows, "A")).PasteSpecial Paste:=xlValues
Range("H14:I14").AutoFill Destination:=Range("H14:I14", Cells(cRows,
"H"))
Range("H14:I14", Cells(cRows, "H")).Copy
Range("H14:I14", Cells(cRows, "H")).PasteSpecial Paste:=xlValues
Range("L14:O14").AutoFill Destination:=Range("L14:O14", Cells(cRows,
"L"))
Range("L14:O14", Cells(cRows, "L")).Copy
Range("L14:O14", Cells(cRows, "L")).PasteSpecial Paste:=xlValues
Range("P14").Copy
Range("P15").Select
Range(Selection, Selection.Offset(cRows - 14, 0)).PasteSpecial
Range("R14:AV14").AutoFill Destination:=Range("R14:AV14", Cells(cRows,
"R"))
Range("R14:AV14", Cells(cRows, "R")).Copy
Range("R14:AV14", Cells(cRows, "R")).PasteSpecial Paste:=xlValues
Range("K14").Copy
Range("K15").Select
Range(Selection, Selection.Offset(cRows - 11, 0)).PasteSpecial
Application.CutCopyMode = False
Range("A1").Offset(cRows, 0).Select
Range("LuseEntry").Copy
ActiveCell.PasteSpecial xlPasteValues
End Sub
for several years with little trouble. However, the macro below fills
in blank cells that have a different number of rows each month. Until
this month, Range commands all began at A11, which worked fine until I
had to insert three rows above it. I didn't think of the impact and of
course the macro referencing cells in row 11 caused this macro to
really make quite a mess.
Below, there are different sets of copy opearations that take place
based on certain colums, and that shouldn't change. However for
anything below that now references row 14, how can I defend the
integrity of the macro if I need to insert or delete rows in the
future? There is no range name defined right now that begins on row
14, but there is a row 11 range name called START, if you wanted to
offset it that way like I did it on the 3rd line of the macro below. I
appreciate the help. I just do these every day anymore to remember all
the tricks available.
Bruce
Sub Fillinblanks()
Dim cRows As Long
cRows = Cells(14, 7).End(xlDown).Row
Range("Start").Offset(3, 0).Select
Range(ActiveCell, ActiveCell.Offset(0, 5)).Select
Range("a14:F14").AutoFill Destination:=Range("A14:F14", Cells(cRows,
"A"))
Range("A14:F14", Cells(cRows, "A")).Copy
Range("A14:F14", Cells(cRows, "A")).PasteSpecial Paste:=xlValues
Range("H14:I14").AutoFill Destination:=Range("H14:I14", Cells(cRows,
"H"))
Range("H14:I14", Cells(cRows, "H")).Copy
Range("H14:I14", Cells(cRows, "H")).PasteSpecial Paste:=xlValues
Range("L14:O14").AutoFill Destination:=Range("L14:O14", Cells(cRows,
"L"))
Range("L14:O14", Cells(cRows, "L")).Copy
Range("L14:O14", Cells(cRows, "L")).PasteSpecial Paste:=xlValues
Range("P14").Copy
Range("P15").Select
Range(Selection, Selection.Offset(cRows - 14, 0)).PasteSpecial
Range("R14:AV14").AutoFill Destination:=Range("R14:AV14", Cells(cRows,
"R"))
Range("R14:AV14", Cells(cRows, "R")).Copy
Range("R14:AV14", Cells(cRows, "R")).PasteSpecial Paste:=xlValues
Range("K14").Copy
Range("K15").Select
Range(Selection, Selection.Offset(cRows - 11, 0)).PasteSpecial
Application.CutCopyMode = False
Range("A1").Offset(cRows, 0).Select
Range("LuseEntry").Copy
ActiveCell.PasteSpecial xlPasteValues
End Sub