First-time Use Code

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

Guest

I would like to have an operation used the first time that a workbook is
opened, but not ever again after that. I know how to designate code that
runs when a workbook opens, but only once. I supposed I can 'brute force' it
by writing code that erases a button once it's clicked, but I'm hoping there
is something like a 'workbook-open' function.

Thanks in advance.
 
Private Sub Workbook_Open()
On Error Resume Next
If Not Evaluate(ThisWorkbook.Names("___FirstTime").RefersTo) Then
MsgBox "This is the first time"
ThisWorkbook.Names.Add Name:="___FirstTime", RefersTo:="=TRUE"
ThisWorkbook.Names("___FirstTime").Visible = False
ThisWorkbook.Save
End If
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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