Using a macro to open an existing workbook

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

Guest

I have a jobs list in a work book named Jobs & Jobs Sheets in a folder called
Job Sheets.
I want to select a job in Jobs & run a macro that opens the job sheet that
has the name in the activecell.
If the job sheet does not exist then I want a job sheet created from a
template in the the job sheet folder.
 
Dim sh As Worksheet
Dim mpName As String

On Error Resume Next
Set sh = Worksheets(ActiveCell.Value)
On Error GoTo 0
If sh Is Nothing Then
mpName = ActiveCell.Value
Set sh = Worksheets.Add
sh.Name = mpName
End If
sh.Activate

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Thanks Bob, That works but I should have said the jobsheet is actually a
workbook so I will fiddle with your code to make it open or create a
workbook. I'll let you know how I go
Chris marwick NZ
 
Back
Top