PDA

View Full Version : [SOLVED] Adding cells via button



donnyp02
11-07-2013, 01:22 AM
Hello everyone,

I assure you I searched before posting this, everything I could find was way above my level and more complicated then what I'm trying to do. I have a form that I fill out, and want to be able to press a form button to add the fields in the form to a master list.

I'm trying to figure out how to add for instance A1 to the value of A30, and make that the new value of A30, and also clear the contents of A1 when the buttons is pressed. I even go a hold of a couple books on VBA for starters, no idea why I couldn't find something so simple. I tried doing a simple addition function but it didn't work.

Private Sub add_Click()Cells(1, 3).Value = Cells(1, 3) + Cells(16, 3)
End Sub

Thanks in advance for any assistance!

donnyp02
11-07-2013, 02:06 AM
I figured out I had the references in Cells(,) wrong, got that fixed and they are properly adding. Now I have to clear them all. I could set each cell's value individually to 0, that would take a very long time to program, how do you clear a range of cells?

Thanks again!

donnyp02
11-07-2013, 02:17 AM
:rofl:
Range("A1:A5").Select
Selection.ClearContents

Ok, so now how do I add a range of cells so I do not have to put a line for every pair of cells I want to add.

donnyp02
11-07-2013, 07:52 AM
For instance I need to add cells B4-B80 on sheet 1 to the contents of the same range on sheet 2, is this possible?

donnyp02
11-07-2013, 06:13 PM
Did I do something wrong? There have been a dozen way much more complicated threads addressed since I've posted mine, and yet still no replies, guess its time to find another board, thanks anyways.