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

Kayslover

Board Regular
Joined
Sep 22, 2020
Messages
136
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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,259
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Kayslover

Board Regular
Joined
Sep 22, 2020
Messages
136
Office Version
  1. 2013
Platform
  1. Windows
Fluff,

Worked like a charm, many thanks for your time and effort, really apprecaited.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,259
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,231
Messages
5,600,427
Members
414,384
Latest member
joehalks

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
Top