G
Guest
I have a list of data the is in 4 columns, and the number of rows will vary
from week to week.. Columns A-C are filled with data, and Column D will only
have data in certain cells (ie, row 6 could have a value and then the next
row to have a value could be row 20...and this value may or may not be
different than the value in row 6). I am trying to wrote code that will fill
in the blanks in column D, so it would copy the value in row 6 to all blank
cells below it until is finds another value (7-19 in my example). Then it
will find the next value and copy that to all blank rows below it, and so on
until all cells are filled. It's working fine except that the length of the
report varies from week to week, so my code will error out when it comes to
the bottom of the worksheet. Is there a way to write code to check for the
cell reference, and then stop if it = a certain cell? (D65536 for example)
My code:
Range("D2").Select
Selection.Copy
' FIND END OF THE RANGE
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
' MOVE END OF RANGE UP ONE CELL AND SELECT ENTIRE RANGE
Range(Selection, Selection.End(xlDown).Offset(-1, 0)).Select
' PASTE TO ENTIRE RANGE
ActiveSheet.Paste
' FIND END OF THE RANGE
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
' SELECT NEXT CELL TO COPY
ActiveCell.Offset(-1, 0).Range("A1").Select
Selection.Copy
from week to week.. Columns A-C are filled with data, and Column D will only
have data in certain cells (ie, row 6 could have a value and then the next
row to have a value could be row 20...and this value may or may not be
different than the value in row 6). I am trying to wrote code that will fill
in the blanks in column D, so it would copy the value in row 6 to all blank
cells below it until is finds another value (7-19 in my example). Then it
will find the next value and copy that to all blank rows below it, and so on
until all cells are filled. It's working fine except that the length of the
report varies from week to week, so my code will error out when it comes to
the bottom of the worksheet. Is there a way to write code to check for the
cell reference, and then stop if it = a certain cell? (D65536 for example)
My code:
Range("D2").Select
Selection.Copy
' FIND END OF THE RANGE
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
' MOVE END OF RANGE UP ONE CELL AND SELECT ENTIRE RANGE
Range(Selection, Selection.End(xlDown).Offset(-1, 0)).Select
' PASTE TO ENTIRE RANGE
ActiveSheet.Paste
' FIND END OF THE RANGE
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
' SELECT NEXT CELL TO COPY
ActiveCell.Offset(-1, 0).Range("A1").Select
Selection.Copy