Consulting

Results 1 to 4 of 4

Thread: Incrementing value in a cell depending on clicking of a macro button

  1. #1
    VBAX Regular
    Joined
    Jul 2023
    Posts
    12
    Location

    Question Incrementing value in a cell depending on clicking of a macro button

    Hi

    I want a cell "b9" to get incremented by 1 automatically whenever the macro "SaveFile" is being clicked. Please help me by suggesting an appropriate code snippet for the above query

    Thanks!
    Last edited by Decatron; 07-04-2023 at 11:51 PM.

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,194
    Location
    Welcome to the forum,

    Maybe add the below line to your SaveFile macro:

    Range("B9") = Range("B9") +1
    Or
    Sheet1.Range("B9") = Sheet1.Range("B9") + 1
    Or
    Sheets("Sheet1").Range("B9") = Sheets("Sheet1").Range("B9") + 1
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post (you may need to click 'Go Advanced')

    Excel 365, Version 2403, Build 17425.20146

  3. #3
    VBAX Regular
    Joined
    Jul 2023
    Posts
    12
    Location
    Quote Originally Posted by georgiboy View Post
    Welcome to the forum,

    Maybe add the below line to your SaveFile macro:

    Range("B9") = Range("B9") +1
    Or
    Sheet1.Range("B9") = Sheet1.Range("B9") + 1
    Or
    Sheets("Sheet1").Range("B9") = Sheets("Sheet1").Range("B9") + 1

  4. #4
    VBAX Regular
    Joined
    Jul 2023
    Posts
    12
    Location
    Thanks for the help. It worked.

Posting Permissions

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