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

Thread: counter in excel ?

  1. #1


    How can I put in a counter in the folder, it may be visible, and save it ? What I'd like to become is, next time I open a new folder the counter should be increased by one, only when I've saved the previous one. Macro's ?


  2. #2
    MrExcel MVP lenze's Avatar
    Join Date
    Feb 2002
    Helena, MT
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)


    This should do what you want

    First, Define a Named Range "Counter" in you excel Worksheet

    Then, place this code in the ThisWorkbook module.

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    Dim myCounter As Variant

    myCounter = Range("Counter").Value
    myCounter = myCounter + 1
    Range("Counter").Value = myCounter

    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