Results 1 to 12 of 12
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Increase particular number... (2000)

    In Private Sub Workbook_Open() have a macro to increase VERSIONE.
    I want to increase VERSIONE for each opening of workbook. in this mod:

    first openini VERSIONE 00.00.00
    second opening VERSIONE 00.00.01
    third opening VERSIONE 00.00.02
    ...

    ecc...

    but when the last two cahracter is 10 increase the cahracter 3 and 4 in 01 and reset to 00 the last 2 caharcter...
    ecc..

    when the caharacter 3 and 4 is 10 increase the first two in 00+1 reste to 00 the last two and 3 and 4 character...
    in effect i want to use a particular count with thwe format ##.#.###...

    Hope i am clear;-(

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Increase particular number... (2000)

    Try this:

    Private Sub Workbook_Open()
    Dim WS_T As Worksheet
    Set WS_T = Sheets("TABELLA")
    Dim Versione As Long

    Versione = 100 * WS_T.Range("K1") + 10 * WS_T.Range("L1") + WS_T.Range("M1")
    Versione = Versione + 1

    WS_T.Range("K1") = Versione 100
    WS_T.Range("L1") = Versione 10 Mod 10
    WS_T.Range("M1") = Versione Mod 10
    End Sub

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Increase particular number... (2000)

    Hans tk for code!
    But sorry me for duplicate post, because browser go in error and not sure to send the message.
    Sorry.

  4. #4
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Increase particular number... (2000)

    wORK PERFECT!!!!!!!!!!!!
    note:
    About a few years my fixed question is:
    But how to Hans undesrtand me in "one shot", peraphs is a good feeling or extrasensorial effect?
    <img src=/S/bash.gif border=0 alt=bash width=35 height=39> <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23> <img src=/S/doctor.gif border=0 alt=doctor width=25 height=33> <img src=/S/alien.gif border=0 alt=alien width=14 height=15> <img src=/S/confused3.gif border=0 alt=confused3 width=45 height=45> ...

  5. #5
    4 Star Lounger
    Join Date
    May 2002
    Location
    US
    Posts
    439
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Increase particular number... (2000)

    Hans,
    I like the idea of incrementing for versions. I have the same need. However, I applied the code you provided, and I am getting a syntax error. Both of the DIM lines turn red.


    I am using the workbook provided in the orginal question.


    Brad

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Increase particular number... (2000)

    Did you copy the code from the Lounge page itself or from the e-mail notification/digest (if you receive that)? The e-mail version sometimes gets mangled.

  7. #7
    4 Star Lounger
    Join Date
    May 2002
    Location
    US
    Posts
    439
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Increase particular number... (2000)

    Hans,
    Straight from the post. I checked for "goofy" chars, etc... did not see any.

    Brad

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Increase particular number... (2000)

    And did you put the code in the ThisWorkbook module?

  9. #9
    4 Star Lounger
    Join Date
    May 2002
    Location
    US
    Posts
    439
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Increase particular number... (2000)

    Hans,
    Yes, I placed it in ThisWorkbook. As it is displayed on the screen, the 2 Dim lines are RED. I deleted the spaces just before the Dim, and re-spaced over. This made the RED go away. Now I get a Compile Error Highlighting the Second line of code, specifically the WS_T after Set. Says Sub or Function not defined. I then removed the spaces just before Set. Now I get Runtime error '424' Object Required.

    this is exactly what is on the ThisWorkbook


    Private Sub Workbook_Open()
    Dim WS_T As Worksheet
    Set WS_T = Sheets("TABELLA")
    Dim Versione As Long

    ****Versione = 100 * WS_T.Range("K1") + 10 * WS_T.Range("L1") + WS_T.Range("M1")
    ****Versione = VERSIONE + 1

    ****WS_T.Range("K1") = VERSIONE 100
    ****WS_T.Range("L1") = VERSIONE 10 Mod 10
    ****WS_T.Range("M1") = VERSIONE Mod 10
    End Sub

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Increase particular number... (2000)

    I don't have the slightest idea what you're doing wrong. I have attached a version of the workbook that works for me (if you enable macros).
    Attached Files Attached Files

  11. #11
    5 Star Lounger
    Join Date
    Aug 2004
    Location
    Connecticut, USA
    Posts
    816
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Increase particular number... (2000)

    You need to change the TABELLA to the actual name of one of your worksheets

    For example
    change

    Set WS_T = Sheets("TABELLA")

    to

    Set WS_T = Sheets("Sheet1")

  12. #12
    4 Star Lounger
    Join Date
    May 2002
    Location
    US
    Posts
    439
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Increase particular number... (2000)

    Well, the only thing I see different, is that I did not have the Option explicit. Everything else was the same.

    But this will come in handy.


    Regards
    Brad

Posting Permissions

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