Using a macro to open an existing workbook

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.
 
B

Bob Phillips

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)
 
G

Guest

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
 

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

Top