Goal seek with Variable

drewbsking

New Member
Joined
Nov 3, 2011
Messages
34
Beginner here trying to get goal seek to work for my needs.

I would like the goal to be a var because it changes based on a pipe size which correlates to a specific slope to be used in the goal seek. Can this be done?

The code below does not work. But it was what I was thinking.

Code:
Sub PipeGoalSeek()
Dim Slope As Integer

Slope = VLookup(Range("AK" & ActiveCell.Row), PipeArray, 5, False)

Range("BX" & ActiveCell.Row).Goalseek Goal:=Slope, ChangingCell:=Range("AY" & ActiveCell.Row)

'Can I put the value that would go into Range("AY" & ActiveCell.Row) into another varibile (say **result**) to be placed into a mround function like below?

Range("AY" & ActiveCell.Row) = "=Mround(**result**,0.05)"
End Sub
 
Last edited:

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Can I define a variable from vlookup? or do i have to use a bunch of if statements?

Sub Macro2()

Dim myvarible As Integer

' IS THIS EVEN POSSIBLE?
myvarible = VLookup(Range("J23"), Table, 2, False)

MsgBox ("The var is: " & myvarible)

I dont want to place this variable anywhere on the sheet.
 
Last edited:
Upvote 0
Now Im cooking with fire.

Code:
Dim myvarible As Integer

myvarible = Application.WorksheetFunction.VLookup(1, Range("Table"), 2, False)

MsgBox ("The var is: " & myvarible)
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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