ms-error-1004

I am seeing the runtime error message “1004” [duplicate]

倾然丶 夕夏残阳落幕 提交于 2019-12-23 07:05:10
问题 This question already has answers here : Run-Time error 1004 Excel 2013 (2 answers) Closed 3 years ago . I am seeing "Run-time Error 1004" at lastrow = Sheet1.Cells(Rows.Count, 1).End(x1Up).Row in my code: Sub copycolumns() Dim lastrow As Long, erow As Long lastrow = Sheet1.Cells(Rows.Count, 1).End(x1Up).Row For i = 2 To lastrow If Sheet1.Cells(i, 6) = "Algiers" Then Sheet1.Cells(i, 1).Copy erow = Sheet2.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row Sheet1.Paste Destination:=Worksheets(

Range Only Works When Called from the Referenced Worksheet [duplicate]

女生的网名这么多〃 提交于 2019-11-28 06:33:07
问题 This question already has answers here : Excel VBA, getting range from an inactive sheet (3 answers) Closed 12 months ago . VBA/Programming newbie here! I've got a macro assigned to two buttons, each on a different worksheet: "Print Page 1" and "Optimization". The macro takes information from the first to know how many times to copy a range the second. When called while "Optimization" is active, the code works perfectly, but when called with the "Print Page 1" worksheet active, a "1004 error: