PDA

View Full Version : how to skip a VBA code if it already exist - Rename worksheet



woesofwomen
07-25-2014, 12:07 AM
Hi Guys,

I have a code below that help me to rename a worksheet. But what if that worksheet name already exist while running the code and wish to skip that step so it wont return an error.?
What code can i add to aid me.

Sheets("Sheet1").Name = "Final"

Bob Phillips
07-25-2014, 03:00 AM
Off the top


Set ws = Nothing
On Error Resume Next
Set ws = Worksheets("Final")
ON Error Goto 0
If ws Is Nothing Then Worksheets("Sheet1").Name = "Final"