I am having an issue with a Error 1004 "Application-defined or Object-defined error" when selecting a range.
I am still able to select rows (ie Rows("21:21").select
) and to select ranges in other sheets of the same workbook. I do not believe the error is in the code. Maybe its some setting I am unaware of?
I have used the exact same code many times before but for some reason I cannot make it function in this sub (I have commented where the error occurs)...
Sub CopySheet1_to_PasteSheet2()
Dim CLastFundRow As Integer
Dim CFirstBlankRow As Integer
'Finds last row of content
Windows("Excel.xlsm").Activate
Sheets("Sheet1").Activate
Range("C21").Select
'>>>Error 1004 "Application-defined or Object-defined error" Occurs
Selection.End(xlDown).Select
CLastFundRow = ActiveCell.Row
'Finds first row without content
CFirstBlankRow = CLastFundRow + 1
'Copy Data
Range("A21:C" & CLastFundRow).Select
Selection.Copy
'Paste Data Values
Sheets("PalTrakExport PortfolioAIdName").Select
Range("A21").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Bring back to top of sheet for consistancy
Range("A21").Select
Range("A1").Select
End Sub
I need to get all fancy in my copying as the amount of rows will change frequently. Again, the below code has been used before without error... but not in this instance.
Dim CLastFundRow As Integer
Dim CFirstBlankRow As Integer
'Finds last row of content
Windows("Excel.xlsm").Activate
Sheets("Sheet1").Activate
Range("C21").Select
'>>>Error 1004 "Application-defined or Object-defined error" Occurs
Selection.End(xlDown).Select
CLastFundRow = ActiveCell.Row
'Finds first row without content
CFirstBlankRow = CLastFundRow + 1
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…