Multiply macro across multiple cells

slice_of_pineapple

New Member
Joined
Feb 9, 2015
Messages
5
Im looking to create a macro that allows me to input data into 7 cells and have the button then multiply the numbers with a cell two rows down and post the total in another cell.

so it will look like this. [TABLE="width: 500"]
<tbody>[TR]
[TD]Monday[/TD]
[TD]Tuesday[/TD]
[TD]Wednesday[/TD]
[TD]Thursday[/TD]
[TD]Friday[/TD]
[TD]Saturday[/TD]
[TD]Sunday[/TD]
[/TR]
[TR]
[TD]71[/TD]
[TD]85[/TD]
[TD]84[/TD]
[TD]90[/TD]
[TD]54[/TD]
[TD]56[/TD]
[TD]56[/TD]
[/TR]
[TR]
[TD]30[/TD]
[TD]30[/TD]
[TD]30[/TD]
[TD]30[/TD]
[TD]30[/TD]
[TD]30[/TD]
[TD]30[/TD]
[/TR]
[TR]
[TD]20[/TD]
[TD]20[/TD]
[TD]20[/TD]
[TD]20[/TD]
[TD]20[/TD]
[TD]20[/TD]
[TD]20[/TD]
[/TR]
[TR]
[TD]1420[/TD]
[TD]1700[/TD]
[TD]1680[/TD]
[TD]1800[/TD]
[TD]1080[/TD]
[TD]1120[/TD]
[TD]1120[/TD]
[/TR]
</tbody>[/TABLE]

What i want is to multiply whats in the first row of numbers with whats in the third row of numbers and post the total in the final row. So take monday for example. I want to multiply 71 x 20 and post the result of 1420 at the bottom. I can create a macro for one column but not all 7. I don't want to have 7 buttons, just one.

Any help with this would be great. And also a how too for future reference would be great.

cheers
 
Assuming the header "Monday" is in cell A1:
Code:
Sub Pineapple()
Dim R As Range
Set R = Range("A1").CurrentRegion
For i = 1 To 7
    R.Rows(5).Cells(i).Value = R.Rows(2).Cells(i) * R.Rows(4).Cells(i)
Next i
End Sub
 
Upvote 0
So all you want the script to do is the multiplication for you is that correct? We will need to know what column and row numbers your data will be in.
I do wonder why you do not just enter a formula in the cell where you want to see the results. Such as =A2*A4.
 
Upvote 0

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