+ Reply to Thread
Results 1 to 5 of 5

How to increment add +1 and keep in memory

  1. #1
    Registered User
    Join Date
    02-02-2020
    Location
    Brussels
    MS-Off Ver
    2016
    Posts
    25

    How to increment add +1 and keep in memory

    Hello,

    I want to count the number of times a value (that has Randbetween function) displays the number 100.
    But when that cell displays another number than 100, I want the counter to keep in memory how many times 100 had appeared.

    I provided a basic picture to explain it better.

    Excel.png

    Thank you
    Last edited by Janna One Trick; 01-12-2022 at 05:58 AM.

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: How to increment add +1 and keep in memory

    You could use a UDF with a static variable, although that will be cleared when you close the workbook.

    In a standard module:

    Please Login or Register  to view this content.
    Then in B3, put the formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-02-2020
    Location
    Brussels
    MS-Off Ver
    2016
    Posts
    25

    Re: How to increment add +1 and keep in memory

    Wow, that's exactly it!
    I can even make copies of it in the same module for another value, 99 instead of 100 and so on.
    Thank you very much!

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: How to increment add +1 and keep in memory

    But be careful! CountNum100 function should only be used for one cell.
    Suppose you have three cells A1, B1, and C1 that contain the function =RANDBETWEEN(1,100). In cells A3, B3, and C3, you will use =CountNum100(A1), =CountNum100(B1), =CountNum100(C1), respectively. The results in cells A3:C3 will return the sum of all occurrences of 100 in cells A1:C1, not each one individually. Besides, at any given moment, each of the cells of the range A3:C3 may show a false value of the sum.

    Artik

  5. #5
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: How to increment add +1 and keep in memory

    If you wanted it for multiple cells you could maybe use a dictionary

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Increment by 1 if email is send else no increment.
    By A9kurs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-03-2021, 01:25 PM
  2. Excel/VBA/ADO - Import - use up memory and won't release used memory after import
    By Thomas Gram in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-07-2019, 06:55 AM
  3. [SOLVED] Thrashing VBA Memory Leaks. Memory Loop Problems. Uncleared Memory in .Match Range Object
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-10-2017, 05:17 PM
  4. Replies: 1
    Last Post: 12-08-2011, 08:52 AM
  5. Need VBA to find out memory and virtual memory used by thread
    By Yozhik in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2011, 08:31 AM
  6. Out of Memory:Is there any way in which I can restore the memory that got used up dur
    By c.vaibhav in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2009, 07:15 AM
  7. Increment/Increment letter in alphabetical order
    By Neil Goldwasser in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2006, 05:10 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1