VBA Function - Multiplication

NinaE_11

Board Regular
Joined
Aug 18, 2020
Messages
54
Office Version
  1. 2016
Platform
  1. Windows
Hello,
I've got a table of data I'm trying to work with and unsure how to set up a VBA Function to multiply Column E x Column F, and entering the product into Column G. I would like to copy that formula down to the entire list (using xlDown because there is a variable number of rows), and then sum the Column G in cell G11.

Column titles/headers are in row 9; data starts in row 13, with spaces in rows 10 and 12. I'd like to keep the empty rows, but unsure how to make a function operate with them?

Any help would be appreciated, Thank you!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
TickerDescriptionQuantityEnd MV% WgtMkt CapWtd Mkt
Total394,287,830.78
ABCABC Corp33,125.009,608,900.002.44%16,202
DEFDEF Corp11,240.003,264,995.200.83%14,967
GHIGHI Corp21,714.005,754,427.141.46%11,902
JKLJKL Corp38,183.0010,506,434.282.66%10,517
MNOMNO Corp139,776.0011,317,662.722.87%10,066
PQRPQR Corp54,389.0010,086,983.942.56%9,761
STUSTU Corp41,500.005,782,195.001.47%8,064
VWXVWX Corp28,607.004,317,082.371.09%7,923
YZYZ Corp53,940.007,184,808.001.82%7,168


My Goal is to take % Wgt column x Mkt Cap Column and enter product into Wtd Mkt column; Summing the column in the second row from the top.
 
Upvote 0
VBA Code:
Sub Maybe()
Dim lr As Long
lr = Cells(Rows.Count, 5).End(xlUp).Row
    With Range("G13:G" & lr)
        .Formula = "=RC[-1] * RC[-2]"
        .Value = .Value
    End With
Range("G11").Value = Application.Sum(Range("G13:G" & lr))
End Sub
 
Upvote 0
Wonderful work, jolivanes! Worked perfectly, thank you so much!
 
Upvote 0
Glad it worked for you and thanks for letting us know.
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,674
Members
449,248
Latest member
wayneho98

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