Got two sheets holding data, formatted as table. This format is necessary as I'm using this data in pivot tables and graphs, and number of rows in use may vary from report to report.
When I try to update data in sheets FU and LU, I'm getting an error trying to delete old data. Error only appear when trying to update sheet LU...
Sheets FU and LU holds data in row 1 to 3 that I want to keep, so I'm trying to delete from row 4 and down (A1 to A3 holds data in both tables, and so does A4 and down).
Here's my code:
Error appear in this line:
Range("A4:L" & lr).EntireRow.Delete
But only when trying to delete from sheet LU...
This is a mystery to me, as both tables in sheet FU and LU and code in use is exactly the same.
Anyone that knows what's going on here? And how to fix it...
When I try to update data in sheets FU and LU, I'm getting an error trying to delete old data. Error only appear when trying to update sheet LU...
Sheets FU and LU holds data in row 1 to 3 that I want to keep, so I'm trying to delete from row 4 and down (A1 to A3 holds data in both tables, and so does A4 and down).
Here's my code:
Code:
'New data sheet FU
Sheets("FU").Select
lr = Range("A" & Rows.Count).End(xlUp).Row
Range("A4:L" & lr).EntireRow.Delete
Windows("ReportLU.xlsx").Activate
Sheets(1).Select
lr = Range("A" & Rows.Count).End(xlUp).Row
Range("A2:L" & lr).Copy
Windows("Dash.xlsm").Activate
Sheets("FU").Select
Range("A4").PasteSpecial
'New data sheet LU
Sheets("LU").Select
lr = Range("A" & Rows.Count).End(xlUp).Row
Range("A4:L" & lr).EntireRow.Delete
Windows("ReportLU.xlsx").Activate
Sheets(1).Select
lr = Range("A" & Rows.Count).End(xlUp).Row
Range("A2:L" & lr).Copy
Windows("Dash.xlsm").Activate
Sheets("LU").Select
Range("A4").PasteSpecial
Error appear in this line:
Range("A4:L" & lr).EntireRow.Delete
But only when trying to delete from sheet LU...
This is a mystery to me, as both tables in sheet FU and LU and code in use is exactly the same.
Anyone that knows what's going on here? And how to fix it...
Last edited: