Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub DeleteReceipts()
- 'macro to delete all sheets in workbook
- 'keep database sheet and one report sheet
- Dim ChrisSheet As Worksheet 'declare worksheet variable
- Application.DisplayAlerts = False 'switch off confirmation dialogue box
- For Each ChrisSheet In ActiveWorkbook.Sheets 'loop through sheets in workbook
- If ChrisSheet.Index > 6 Then 'if the Sixth sheet or greater
- ChrisSheet.Delete 'delete the sheet
- End If 'close if statement
- Next ChrisSheet 'close loop
- Application.DisplayAlerts = True 'switch confirmation dialogue box back on
- End Sub
- Sub deleterows()
- Dim lastrow
- 'Finding the lastrow in Column A
- lastrow = ThisWorkbook.Sheets(1).Range("A2:N50000").ClearContents
- lastrow = ThisWorkbook.Sheets(2).Range("A2:E50000").ClearContents
- lastrow = ThisWorkbook.Sheets(4).Range("A2:O50000").ClearContents
- 'Deleting the cell contain 1 in Column A
- For i = lastrow To 2 Step -1
- 'Finding the cell which contain 1 in Column A
- If ThisWorkbook.Sheets(1).Cells(i, 2) = "Number" Then
- ThisWorkbook.Sheets(1).Rows(i).EntireRow.Delete
- End If
- Next i
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement