ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   adding ranges (https://www.excelbanter.com/excel-programming/346144-adding-ranges.html)

[email protected]

adding ranges
 
how do i make a button that adds
two ranges together
i.e
adds a1 to c1, a2 to c2 etc..
and places these values in the "a" column where the previous values were
thanks for the help

Chip Pearson

adding ranges
 
Use code like the following:

Dim Rng As Range
For Each Rng In Range("A1:A10")
Rng.Value = Rng.Value + Rng(1, 3).Value
Next Rng

Change the A1:A10 to the appropriate range.

I



" wrote
in message
...
how do i make a button that adds
two ranges together
i.e
adds a1 to c1, a2 to c2 etc..
and places these values in the "a" column where the previous
values were
thanks for the help




Tom Ogilvy

adding ranges
 
Sub AddValues()
Dim cell as Range
if Selection.Columns.count 1 then exit sub
if selection.Column < 1 then exit sub
for each cell in selection
if isnumeric(cell.value) and isnumeric(cell.offset(0,2).Value) then
cell.Value = cell.Value + offset(0,2).Cell.Value
end if
Next
End Sub

select the cells in column A that you want to update and run the macro. You
can also manually select the column of contiguous cells in column C, then do
Edit=Copy, then select the first cell in column A and do Edit=Paste
Special and select Values and Add.

--
Regards,
Tom Ogilvy

" wrote in message
...
how do i make a button that adds
two ranges together
i.e
adds a1 to c1, a2 to c2 etc..
and places these values in the "a" column where the previous values were
thanks for the help





All times are GMT +1. The time now is 02:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com