Ok here is a strange occurance I need some help with. When I run the following code with no data in the source tabs (yes it makes no sense to run with no data but anyway) my macro button is deleted off the page? This does not happen if the code is run with data. Here is a summary of the code:
'P1 through P'12 are the same, I'm only showing P11 & P12 and the delete code.
'P11
Worksheets("ledger").Range("A1:B2700").Copy
.Range("A27001").PasteSpecial xlPasteValues
Worksheets("1st sort").Range("ay1:bc2700").Copy
.Range("c27001").PasteSpecial xlPasteValues
'P12
Worksheets("ledger").Range("A1:B2700").Copy
.Range("A29701").PasteSpecial xlPasteValues
Worksheets("1st sort").Range("bd1:bh2700").Copy
.Range("c29701").PasteSpecial xlPasteValues
.Activate
'FASTER code to delete rows
.Range("F1").sort Key1:=Range("F1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
lFirstRow = .Cells.Find(0, .[f65536].End(xlUp), , xlWhole, , xlNext).Row
lLastRow = .Cells.Find(0, , , xlWhole, , xlPrevious).Row
.Rows(lFirstRow & ":" & lLastRow).EntireRow.Delete
End With
Application.CutCopyMode = False
End Sub
Any ideas?
Thanks
'P1 through P'12 are the same, I'm only showing P11 & P12 and the delete code.
'P11
Worksheets("ledger").Range("A1:B2700").Copy
.Range("A27001").PasteSpecial xlPasteValues
Worksheets("1st sort").Range("ay1:bc2700").Copy
.Range("c27001").PasteSpecial xlPasteValues
'P12
Worksheets("ledger").Range("A1:B2700").Copy
.Range("A29701").PasteSpecial xlPasteValues
Worksheets("1st sort").Range("bd1:bh2700").Copy
.Range("c29701").PasteSpecial xlPasteValues
.Activate
'FASTER code to delete rows
.Range("F1").sort Key1:=Range("F1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
lFirstRow = .Cells.Find(0, .[f65536].End(xlUp), , xlWhole, , xlNext).Row
lLastRow = .Cells.Find(0, , , xlWhole, , xlPrevious).Row
.Rows(lFirstRow & ":" & lLastRow).EntireRow.Delete
End With
Application.CutCopyMode = False
End Sub
Any ideas?
Thanks