Is there a code that anables you tto search for a worksheet

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

Guest

Is there a code that anables you to search for a worksheet by reference to
the Tabs, and if it exsists display the sheet or if it does not exsists
create a new worksheet from a template (say sheet1)?
 
Sub makesheetorgoto()
On Error GoTo makeit
Sheets("joe").Select
Exit Sub
makeit:
Sheets.Add.Name = "joe"
End Sub
 
Thanks very much Don, very useful. Can you tell me the code if I wanted to
use a Userform for the following: On a click og a commandbuttton a userform
appears and asks to insert name of person to check. If this person has a
sheet then it goes to it, if there is no sheet a messagebox asks if you want
to create a new sheet for the person. If yes then copies from a template
(sheet1) and open it.
Would very much appreciate help on this.
Thank you
 
Easier than that would be to just add an input box and a sheet copy .

Sub makesheetorgoto()
ms=inputbox("Name desired")

Sub makesheetorgoto()
ms = InputBox("Enter Name")
On Error GoTo makeit
Sheets(ms).Select
Exit Sub
makeit:
Sheets("sheet1").Copy after:=ActiveSheet
ActiveSheet.Name = ms
End Sub
 

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