VBA goal seek for textboxes RRS feed

  • Question

  • hello everyone,

    i´m trying to find out how can i change the value of a textbox in a form, with a goal seek fromula.

    it´s a form in vba and the code i have is:

        Private Sub CommandButton1_Click()
        Dim val1, val2, val3 As Integer

        val1 = TextBox1.Value
        val2 = TextBox3.Value

        TextBox2.Value = val1 - val3


         End Sub

    It is a simple program you get the values from texbox1 and texbox3 and you get the value in textbox2, with the following operation, texbox2.value = texbox1.value - textbox3.value

    i want to get the value of textbox1 by changing the value of textbox2. i have this macro:

       Sub Macro2()
       ' Macro2 Macro

        Range("").GoalSeek Goal:="", ChangingCell:=Range("")
        End Sub

    how can i change the cells for a textbox value?

    Tuesday, January 29, 2019 11:55 AM


All replies

  • Hello,

    This forum is strictly for VB.NET, for this reason your thread is being moved to Excel for developers as Excel appears to be what you are inquiring about coupled with VBA code. Thanks for understanding.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, January 29, 2019 1:35 PM
  • Hi,

    I recommend to read this article "Excel Goal Seek And The GoalSeek VBA Method: Introductory Tutorial With Examples".

    cf. I hope name of Variables and TextBox will express its meaning ("val1" does not express its meaning).   


    Ashidacchi --

    Wednesday, January 30, 2019 4:56 AM