Wednesday, 3 July 2019

Add/Subtract button Excel VBA

Here is an example of my project in this picture


enter image description here


I like collecting, so I am making an inventory sheet in Excel.


I want to make a way that I can click a button and it affects the next, or previous cell


For example:


Cell C3 would have an Add button, Cell D3 would have the number of copies I have of that item, and Cell E3 would have a Subtract button. By clicking the button in C3, it would add one more to the number in Cell D3. If you click the button in C1, it would subtract from Cell D3. Seems pretty straight forward.


Heres the conditions though:


I have like 200 items per sheet on like 20 sheets (not in the example). I would like some way that I could add the macros to all the buttons without having to make a new macro specific to each button. I also do not want it to work with the selected cell. It needs to affect the cell to the right for the add button and the cell to the left for the subtract button.


I looked everywhere for an answer, and I came pretty close to the solution.


The is the closest thing I could find but its not what i am not what i am ooking for:


 Sub AddOne()
ActiveCell.Value = ActiveCell.Value + 1
End Sub

Sub SubtractOne()
ActiveCell.Value = ActiveCell.Value - 1
End Sub

I hope this makes sense and thank you all for your time.

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...