Macro Use Counter

  • Thread starter Thread starter scantor145
  • Start date Start date
S

scantor145

I'm sure everyone has gone to a website that shows the number of users
who've visited the site. Is it poosible to put such a counter into a
macro so that the next time the initial form opens it displays the
number of times it's been opened?
 
Obviously, to be of any use and the value/count is to be stored in the
workbook, the workbook would have to be saved each time the form is shown.
Is that acceptable? An alternative is to use the registry or a separate
file. The registry is only useful if it is to be used on a single computer.
A separate file would have to be located with the workbook. By the way,
what do you mean by FORM? Do you mean a userform or are you setting up a
worksheet to look like a paper form/webpage?
 
On some obscure worksheet place a named cell "Counter". On your initial
form place a text box and set its "ControlSource" to Counter. Everytime
the macro executes increment Counter

' Code to show Userform

Option Explicit

Sub Test()
UserForm1.Show
End Sub

' Code to increment counter code of Userform

Option Explicit

Private Sub UserForm_Activate()
Range("Counter") = Range("Counter") + 1
End Sub
 

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