+ Reply to Thread
Results 1 to 12 of 12

Change cell value +1 or -1

  1. #1
    Forum Contributor
    Join Date
    12-25-2013
    Location
    istanbul
    MS-Off Ver
    Excel 2007
    Posts
    237

    Change cell value +1 or -1

    Hey my friends,
    I'd like to get two VBA codes to increase and decrease the value in cell A1 one by one.
    If A1 value is 23, when I run "increase VBA", A1 should be 24. or if I click to run "decrease VBA" , it should be 22. and so on. Also it should continue to run. I mean, If I click to run "decrease VBA" three times in a row, cell value should be 20.
    Can you help me with it please? Thank you.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Excel 2016
    Posts
    4,346

    Re: Change cell value +1 or -1

    Hi aaaaa34,

    Assuming the buttons are on the same sheet as the A1 value (otherwise the sheet needs to be referenced in the code):

    Please Login or Register  to view this content.
    I've put in the check for A1 being numeric to avoid any errors.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Valued Forum Contributor nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    excel 2016 64bit
    Posts
    1,517

    Re: Change cell value +1 or -1

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    12-25-2013
    Location
    istanbul
    MS-Off Ver
    Excel 2007
    Posts
    237

    Re: Change cell value +1 or -1

    Quote Originally Posted by nigelog View Post
    .
    Thank you so much for your fast response bro.
    I want to ask you that f i want to run this code for E5 cell for example, how I should modify these "Cells(1, 1).Value = Cells(1, 1).Value + 1"

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Excel 2016
    Posts
    4,346

    Re: Change cell value +1 or -1

    Well you could use Range instead of Cells if that makes it easier (see my post) or just edit Cells(1,1) to Cells(5,5). The syntax for "Cells" is (row number, column number)

  6. #6
    Valued Forum Contributor nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    excel 2016 64bit
    Posts
    1,517

    Re: Change cell value +1 or -1

    As Arkadi said - change to either
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    12-25-2013
    Location
    istanbul
    MS-Off Ver
    Excel 2007
    Posts
    237

    Re: Change cell value +1 or -1

    Oke nigel de jong. Now i got it.
    arkadiusz milik, thank you so much too for post #2. It works great.
    both of your names reminded me these players : )

    I want to use your codes with some modifications.
    Thank you.
    Last edited by aaaaa34; 06-14-2019 at 10:10 AM. Reason: I will submit my request in new thread.

  8. #8
    Valued Forum Contributor nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    excel 2016 64bit
    Posts
    1,517

    Re: Change cell value +1 or -1

    That is a different question and should be the subject of a new thread. Other participants may get involved to help find your answer if you do. If this first question has been answered then please mark thread as solved and start with a new thread with an accurate description of what you are hoping to achieve. Rgds

  9. #9
    Forum Contributor
    Join Date
    12-25-2013
    Location
    istanbul
    MS-Off Ver
    Excel 2007
    Posts
    237

    Re: Change cell value +1 or -1

    oke nigel.
    If Arkadi doesn't want to reply here too, I will open a new thread.
    Now I mark this thread solved so fast. Thank you.

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Excel 2016
    Posts
    4,346

    Re: Change cell value +1 or -1

    aaaaa34, nigel was right that it is a different request, and since he already asked for a new thread to be created, I will respect that. Happy to help if you start a new one though

    p.s. I guess you are a big soccer fan?

  11. #11
    Forum Contributor
    Join Date
    12-25-2013
    Location
    istanbul
    MS-Off Ver
    Excel 2007
    Posts
    237

    Re: Change cell value +1 or -1

    off course I love soccer a lot and follow all european soccer leagues.
    Arkadiusz Milik, plays for Napoli, not big star like Lewandowski, but very talented and they score a lot together for Poland : ))))

  12. #12
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Excel 2016
    Posts
    4,346

    Re: Change cell value +1 or -1

    Cool
    Once you start a new thread for the new question about max/min restrictions, I can give you some code for that.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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