thole
04-07-2008, 05:50 AM
I want to delete a sheet if its name equals a certain cell's value.
Ihave the following code; which gives me an error when trying to delete the sheet:
Sub DeleteWorksheet()
Worksheets("Hidden_Calculations").Select
Last = Cells(Rows.Count, "B").End(xlUp).Row
For i = Last To 10 Step -1
If (Cells(i, "B").Value) = [Sheet2!$c$6] Then
Cells(i, "B").EntireRow.Delete
End If
Next i
For Each sht In ActiveWorkbook.Sheets
If Sheet.Name = Sheets(Sheet2).Range("$C$6").Value Then sht.Delete
Next
End Sub
Ihave the following code; which gives me an error when trying to delete the sheet:
Sub DeleteWorksheet()
Worksheets("Hidden_Calculations").Select
Last = Cells(Rows.Count, "B").End(xlUp).Row
For i = Last To 10 Step -1
If (Cells(i, "B").Value) = [Sheet2!$c$6] Then
Cells(i, "B").EntireRow.Delete
End If
Next i
For Each sht In ActiveWorkbook.Sheets
If Sheet.Name = Sheets(Sheet2).Range("$C$6").Value Then sht.Delete
Next
End Sub