Deleteing a worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am looking at a particular cell (E5) and if the word Total is in there I
want it to delete the worksheet.

Not sure why the following code doesn't work. Seemd fairly straight forward.

If Sheets("Baton Rouge").Cell(5, 1) = "TOTAL" Then
Sheets("Baton Rouge").Delete
End If

Thanks,

Kevin Porter
 
If Sheets("Baton Rouge").Cell(5, 1) = "TOTAL" Then

Cell must be Cells
 
VBA is case sensitive unless you've done something special like adding this to
the top of the module:

Option Compare Text


You could also use:
If lcase(Sheets("Baton Rouge").Cells(5, 1).value) = lcase("TOTAL") Then

Or you may want to look at strcomp() in VBA's help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top