LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Need better macro

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to copy and paste values (columns)I have a macro file built C02C04 Excel Programming 2 May 2nd 08 01:51 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 09:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"