VBA copy formula in cell across a row (multiple times for different rows)

jtkerlin

New Member
Joined
Jul 15, 2019
Messages
1
Brand new to vba, I did some searching around, but did not find what I was looking for or did not understand how I would leverage. Likely there is a better way to what I am trying to do.

I have a data table (originally from a pivot table) and added sums for various rows - as users will be able to update the values being summed (I want the totals to update with the new entries), I would like to copy those formulas across multiple columns to the right.

Here is an example of the data I have set up. Users could change the amount for Prod1 for January, or February or March and so forth.

A
B
C
D
E
1
Client
Product
Jan
Feb
Mar
2
ABC
Prod1
10
10
10
3
Prod2
15
0
2
4
Prod Total
25
5
ABC Total
25
6
XYZ
Prod2
15
5
0
7
Prod4
0
0
30
8
Prod8
1
7
9
9
Prod Total
16
10XYZ Total
16

<tbody>
</tbody>

<tbody>
</tbody>
The only determination of which row to have the cell value (formula) copied over is that in Column A and Column B it ends with " Total". Aside from that there could be a variable number of Products for each Client, it could be one, two, twenty, etc. The number of clients I have is well in excess of 1,000 (this is just a snippet).

I would want it to take the formula from C4 and copy to the end of the row (would be to December - not shown), then it would take the formula from C5 and copy to the end of the row, then C9...., then C10, until it reaches the end of the data filed.

Thank you for any help and understanding on this. I know I would need to do some sort of loop to have it repeat, but I cannot figure out how it would identify the rows where I would want the cell value (formula) copied over.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,214,827
Messages
6,121,812
Members
449,048
Latest member
greyangel23

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