making cells zero/empty using vba in excel
Posted on 2012-09-04
Can anybody help with the following?
I have an Excel spreadsheet in which I have a few columns that are summed with a total underneath. For example, a cell that contains a sum uses the following formula
I have added a button to the Worksheet and I would like to use VBA to re-set the values that are being summed to be zero (or better still empty) once the button is pressed.
I suppose I could do this manually by specifying C7 to C20 in the code but, thinking ahead, I would like to be able to deal with the possibility that another row is added in this range. If this were done I would have to change the VBA code.
Can anybody suggest I way I could do this. I would also appreciate some code that would deal with setting the values to zero i.e. I'm new to VBA.
Another thing I want to do is to copy values from one column to another. Again, I would like the code to be able to deal with the possibilities that new rows may be added to the range i.e. I don't have to manually change the VBA code.
Is there a way to do this?
Thanks in advance