VBA for formula to add cells next to merged cell

abschy

New Member
Joined
Mar 20, 2019
Messages
29
Hi all,

Im having issues coming up with a code to add the cells next to a merged cell.

This is an example of the table. the first column does not have merged rows, but the second does. I need the second column to be the sum of the first column ..

my data starts on the 4th row, and the 8th column.

this is the code i have now:

VBA Code:
 With ActiveSheet
    For i0 = 4 To .UsedRange.rows.count
        If Not .Cells(i0, 1).Value = strName Then
            strName = .Cells(i0, 1)
            i1 = i0
        End If
        .Cells(i1, 9).Value = .Cells(i0, 8) + .Cells(i0 + 1, 8).Value
    Next i0
    End With


1
2
3
sum of the 3 cells to the left
1
3
sum of the 2 cells to the left
1
2
sum of the 2 cells to the left
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,214,837
Messages
6,121,883
Members
449,057
Latest member
Moo4247

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top