ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Test for first time a workbook is opened (https://www.excelbanter.com/excel-programming/336586-test-first-time-workbook-opened.html)

Ken Loomis

Test for first time a workbook is opened
 
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



Henry[_5_]

Test for first time a workbook is opened
 
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



"Ken Loomis" wrote in message
...
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




Ken Loomis

Test for first time a workbook is opened
 
Thanks, Henry,

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

Ken


"Henry" wrote in message
...
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



"Ken Loomis" wrote in message
...
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






Henry[_5_]

Test for first time a workbook is opened
 
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


"Ken Loomis" wrote in message
...
Thanks, Henry,

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

Ken


"Henry" wrote in message
...
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



"Ken Loomis" wrote in message
...
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









All times are GMT +1. The time now is 06:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com