Insert formulas in the all rows of a column depending on another column that has data.

Kayslover

Board Regular
Joined
Sep 22, 2020
Messages
168
Office Version
  1. 2013
Platform
  1. Windows
I have a macro that I got off the Internet that creates a sheet called “Summary-Sheet”.

The sheet is created by going through the workbook and for each Sheet, it inserts the sheet name in Sheet “Summary-Sheet” along with a couple pieces of data in Columns B and C.

Summary-Sheet has data in columns A, B and C and Row 1 contains headings.

In column E, I would like to have the formula =D2*E2. This formula would have to go down as far as the last row that has data in Column A.

I would like to have a formula in the last row +1 in Column E that would sum all the rows.

Appreciate any help offered.
 
Ok, try
VBA Code:
Sub Kayslover()
   With Range("E2:E" & Range("A" & Rows.Count).End(xlUp).Row)
      .FormulaR1C1 = "=rc[-2]*rc[-1]"
      With .Offset(.Rows.Count).Resize(1)
         .FormulaR1C1 = "=sum(r2c:r[-1]c)"
         .Offset(, -4).Value = "TOTAL"
         With .Offset(, -4).Resize(, 5)
            .Font.Color = vbRed
            .Font.Bold = True
         End With
      End With
   End With
End Sub
 
Upvote 0
Solution

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Fluff,

Worked like a charm, many thanks for your time and effort, really apprecaited.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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