calculating variables

kin1

New Member
Joined
Mar 31, 2011
Messages
37
hello, i hope someone can help me with this.

i'm trying to calculate two variables provided by the user through the inputbox. i'm having a hard time getting it calculate.

here's what i have. any suggestions would be great, thanks!

Sub ProrateValue()
Dim NetWeight As Integer
Dim TotalValue As Integer

NetWeight = InputBox("Please enter the Net Weight Value")
TotalValue = InputBox("Please enter the Total Value")

Range("E2").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[2]*netweight)/totalvalue"
Range("E2").Select
Selection.AutoFill Destination:=Range("E2:E100")

End Sub

thanks again.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
See if this gets you headed in the right direction:

Code:
Sub InputNumbers()
Dim var1#
var1 = Application.InputBox("Please enter the Net Weight Value:", "Net weight", Type:=1)
If var1 = False Then Exit Sub
Dim var2#
var2 = Application.InputBox("Please enter the Total Value:", "Total", Type:=1)
If var2 = False Then Exit Sub
Range("E2:E100").FormulaR1C1 = "=SUM(RC[2]*" & var1 & ")/" & var2
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,290
Members
452,902
Latest member
Knuddeluff

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