Captain_Conman
Board Regular
- Joined
- Jun 14, 2018
- Messages
- 54
Hello! I am trying to write a macro that will delete the entire workbook from my desktop if both sheets "100" and "MISC" have no data.
I keep getting a runtime error on the "Kill wb" line. Any thoughts?
I keep getting a runtime error on the "Kill wb" line. Any thoughts?
Code:
Sub Macro1()
Dim wb As Workbook
Dim Test100 As Object
Dim TestMISC As Object
Set wb = Workbooks.Open("C:\Users\qucso1\Desktop\Test.xlsx")
Set Test100 = Sheets("100").Range("A2")
Set TestMISC = Sheets("MISC").Range("A2")
If IsEmpty(Test100) = True And IsEmpty(TestMISC) = True Then
wb.Close SaveChanges:=False
Kill wb
End If
End Sub