Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Counter

  1. #1
    New Member
    Join Date
    Apr 2002
    Location
    East Texas
    Posts
    38
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have been trying to place a code in my userfrom so that when it used an set amount of times it will not work. So I guess my question is, can a counter be placed in a user form so that when a form is used X amount of times the form / application will not work.

    Thanks

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Posts
    363
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I think you would need to use a counter and write the result to disk. Then check against the written result when the macro runs.

    It's never too late to learn something new.

    Ricky

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi

    Try this

    Set a cell say A1 my old fav cell and enter value 0

    now code out so counter = range A1 and then range a1 = counter + 1 so it changes each time opened, add this to some routeen you write and place in Auto_Open()

    so will update each time shhet opened.

    By the way can be date ie if > 10/04/02 then exit or what ever you like.

    other ideas.. your need to say if A1 = or reater than X the exit as error handle thou:

    That kind of idea, and link the user form to this data and script...


    does this help?
    Just some ideas..

    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  4. #4
    New Member
    Join Date
    Apr 2002
    Location
    East Texas
    Posts
    38
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks for the help Jack but the application will still open. What I would like for it to do is to not open at all once the workbook has been opened 5 times. The following is the code I have so far.
    Thanks in advance

    Private Sub Workbook_Open()
    UserForm1.Show
    Dim CounterSum As Integer

    CounterSum = Sheet1.Range("IV65536").Value
    Sheet1.Range("IV65536").Value = CounterSum + 1
    If CounterSum >= 5 Then ThisWorkbook.Close
    End Sub

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •