roxnoxsox
12-22-2015, 04:01 AM
I think my error might be with the selected range to copy maybe..? I'm trying to check if cell in column D is empty and if so, then copy the contents of cell in column C and paste into D. I'm doing this for a very large amount of data. Currently I'm trying to do this through an autofilter (open to other suggestions if anyone knows of a better way!) so that the visible contents of column C are pasted into D. But it's coming up with an error message when I run the macro: (the line beginning 'Range("D2:D" & LR.....' is the line highlighted in Debug)
LR = Cells(Rows.Count, 1).End(xlUp).Row
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("D2:D" & LR).AutoFilter Field:=4, Criteria1:="="
Range("C2", Range("C2").End(xlDown)).Select
Selection.Copy
Range("D2:D" & LR).SpecialCells(xlCellTypeVisible).PasteSpecial xlValues
Rows("1:1").Select
Application.CutCopyMode = False
ActiveSheet.ShowAllData
Selection.AutoFilter
Range("A1").Select
Is this an obvious error? ;_; My range of data will change a lot so I need this to be able to run for however many rows there are which is where the LR comes in.. Thanks in advance!
LR = Cells(Rows.Count, 1).End(xlUp).Row
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("D2:D" & LR).AutoFilter Field:=4, Criteria1:="="
Range("C2", Range("C2").End(xlDown)).Select
Selection.Copy
Range("D2:D" & LR).SpecialCells(xlCellTypeVisible).PasteSpecial xlValues
Rows("1:1").Select
Application.CutCopyMode = False
ActiveSheet.ShowAllData
Selection.AutoFilter
Range("A1").Select
Is this an obvious error? ;_; My range of data will change a lot so I need this to be able to run for however many rows there are which is where the LR comes in.. Thanks in advance!