Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro, input data button 1

Status
Not open for further replies.

Nitha120

Technical User
Feb 22, 2005
33
US
Hi,
how do i make a buttons ask for the user to input the data and the values is insert to the macro to run the calculation.

Here is my codes:

ActiveCell.FormulaR1C1 = "12"
Selection.AutoFill Destination:=Range("C3:C11"), Type:=xlFillDefault

here i want the user to enter 12 so it will fill in cell C3:C11 automatically...

and this one, i want the user to enter 1.56 it will then set .GoalSeek Goal: from range H3 to H11 to the value 1.56 so i can run the macro.


Range("H3").Select
Range("H3").GoalSeek Goal:=1.56, ChangingCell:=Range("E3")
Range("H4").Select
Range("H4").GoalSeek Goal:=1.56, ChangingCell:=Range("E4")Range("H5").Select
Range("H5").GoalSeek Goal:=1.56, ChangingCell:=Range("E5")
Range("H6").Select
Range("H6").GoalSeek Goal:=1.56, ChangingCell:=Range("E6")
Range("H7").Select
Range("H7").GoalSeek Goal:=1.56, ChangingCell:=Range("E7")
Range("H8").Select
Range("H8").GoalSeek Goal:=1.56, ChangingCell:=Range("E8")
Range("H9").Select
Range("H9").GoalSeek Goal:=1.56, ChangingCell:=Range("E9")
Range("H10").Select
Range("H10").GoalSeek Goal:=1.56, ChangingCell:=Rang("E10")
Range("H11").SelectRange("H11").GoalSeek Goal:=1.56,ChangingCell:=Range("E11")


Any help or suggestion is much appreciated guys.

 
Hi,
Code:
iVal = InputBox("enter value")
Range("C3:C11").Value = iVal

'here i want the user to enter 12 so it will fill in cell C3:C11 automatically...
nGoal = InputBox("Enter goal")
'and this one,  i want the user to enter 1.56 it will then set .GoalSeek Goal: from range H3 to H11 to the value 1.56 so i can run the macro.


Range("H3").GoalSeek Goal:=nGoal, ChangingCell:=Range("E3")
Range("H4").GoalSeek Goal:=nGoal, ChangingCell:=Range("E4")
Range("H5").GoalSeek Goal:=nGoal, ChangingCell:=Range("E5")
Range("H6").GoalSeek Goal:=nGoal, ChangingCell:=Range("E6")
Range("H7").GoalSeek Goal:=nGoal, ChangingCell:=Range("E7")
Range("H8").GoalSeek Goal:=nGoal, ChangingCell:=Range("E8")
Range("H9").GoalSeek Goal:=nGoal, ChangingCell:=Range("E9")
Range("H10").GoalSeek Goal:=nGoal, ChangingCell:=Range("E10")
Range("H11").GoalSeek Goal:=nGoal, ChangingCell:=Range("E11")

Skip,
[sub]
[glasses] [red]Be advised:[/red] When you ignite a firecracker in a bowl of vanilla, chocolate & strawberry ice cream, you get...
Neopolitan Blownapart! [tongue][/sub]

 
or....
Code:
iVal = InputBox("enter value")
'here i want the user to enter 12 so it will fill in cell C3:C11 automatically...
nGoal = InputBox("Enter goal")
'and this one,  i want the user to enter 1.56 it will then set .GoalSeek Goal: from range H3 to H11 to the value 1.56 so i can run the macro.

For lRow = 3 To 11
   Cells(lRow, "C").Value = iVal
   Cells(lRow, "H").GoalSeek Goal:=nGoal, ChangingCell:=Cells(lRow, "E")
Next

Skip,
[sub]
[glasses] [red]Be advised:[/red] When you ignite a firecracker in a bowl of vanilla, chocolate & strawberry ice cream, you get...
Neopolitan Blownapart! [tongue][/sub]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top