Thread: Find Worksheet
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Find Worksheet

Sub gotosheet()
Application.Goto Sheets(Range("m1").Value).Range("a1")
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Carlos" wrote in message
...
Seems to be quite a simple one. But I can't figure it out.

Basically I've got a macro that saves a worksheet each month and renames
it.
All works fine, but as this is a shared workbook I want to put a failsafe
in
to make sure the macro to update isn't pressed twice thus trying to create
a
new sheet and save as the name. (because if this happens the macro crashes
(because it can't rename the same).

So I wasn to run a simple If function which searches a workbook for a
name
if it doesn't exist carry on with the code, if it does exist, then it will
create a messagebox.


Something like this but it needs to search the Sheet names not a range.
sub searchmonth ()

Cmonth = ("M1") ' Inthis case February

Set searchrange = workbooks ("export.xls")

Set test = searchrange.find (what= Cmonth)

If test Is Nothing Then

' it runs my code

Else

'MsgBox

End If
End sub


Thanks for any help!

Carl