How to use goal seek function in Excel user function

0 votes

The following code demonstrates how to utilize goal seek in Microsoft Excel. It runs smoothly.

   Sub GSeek() 
      With Worksheets("Sheet1") 
             .Range("H18").GoalSeek _  
              Goal:=.Range("H21").Value, _ 
               ChangingCell:=.Range("G18")
     End With 
   End Sub

And I would like to use a function to do the goal seek like follows.

  Function fSeek(a As Range, b As Range, c As Range)
     a.GoalSeek Goal:=b.Value, ChangingCell:=c
     fSeek = "Ok"
   End Function

The code, however, operated without incident, and the range c received no response. Where have I gone wrong?

Oct 28 in Others by Kithuzzz
• 20,660 points
48 views

1 answer to this question.

0 votes

In the Microsoft Excel Object-Sheet1(Sheet1), we can only write the following code:

 '----------------------------------------------
 ' Goal seeking when the worksheet changes.
 '----------------------------------------------
 ' Here we want to do goal seek for Range("H18") 
 '  with the Goal cell as  Range("H21") 
 '  and  the changing cell as Range("G18").
 '
 Private Sub Worksheet_Change(ByVal Target As Range)
     Range("H18").GoalSeek Goal:=Range("H21"), ChangingCell:=Range("G18")
 End Sub
answered Oct 28 by narikkadan
• 37,660 points

Related Questions In Others

0 votes
1 answer
0 votes
1 answer

How to use VBA in Excel for Google Search?

Try this: Private Const LicenseRegistration As String = ...READ MORE

answered Oct 7 in Others by narikkadan
• 37,660 points
117 views
0 votes
1 answer

Excel Function Goal Seek Equivalent Algorithm in C #

Nuget has libraries available like Trident.GoalSeek and ...READ MORE

answered Oct 17 in Others by narikkadan
• 37,660 points
71 views
0 votes
1 answer

How to use a named column in Excel formulas

Let's say I have the following figures ...READ MORE

answered Oct 24 in Others by narikkadan
• 37,660 points
38 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,720 points
449 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
2,199 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9 in Others by gaurav
• 22,040 points
66 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16 in Others by Edureka
• 13,640 points
199 views
0 votes
1 answer

How to use the INDIRECT function in Excel

Try this: =INDEX(INDIRECT($A$1&"!$1:$1048576"),MATCH($B$1,INDI ...READ MORE

answered Sep 29 in Others by narikkadan
• 37,660 points
66 views
0 votes
1 answer

How to use VLOOKUP function in MS Excel

Here is the formula for cell G2: ...READ MORE

answered Nov 13 in Others by narikkadan
• 37,660 points
23 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP