Test for first time a workbook is opened

K

Ken Loomis

I need a way to tell when a workbook is opened if it is the first time it is
being opened by a user.

Does anyone have any ideas?

Tia,
Ken
 
H

Henry

Ken,

If this is not a shared file then, in a spare cell (say Z99) put "First"

In a module put

Private Sub Auto_Open()
If Range("Z99").Value ="First" Then
Range("Z99").Value =""
code here to do what you want when the file is first opened.
Else
code here to do what you want when the file is opened subsequently
End If

End Sub

If the file is shared you'll have to use a separate cell for each user and
determine who has opened the file.

Look in VBA help for UserName to give you an idea of where to start.

Henry
 
K

Ken Loomis

Thanks, Henry,

It's not a shared workbook. Each user has their own copy, so this will work
great.

Ken
 
H

Henry

Ken,

What I do is create a sheet named "System" to hold all the variables for the
program.
Things like "First", Named ranges that hold Drop Down Box entries, Lookup
tables, in fact anything that is not 'data'.
I hide this sheet, so anyone having a casual look around in my workbook will
not be tempted to change anything important.

Henry
 

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