1

Hi I want to do a data validation , so i have two columns and i would divide each value of row from Column F with each value of row from Colum S + texbox.value (vba), but i don't know how to use the value from my text box in excel formula.

Thanks

1
  • 1
    Depending on object type TextBox1.Value. Replace TextBox1 with the appropriate textbox name. Commented Jul 9, 2018 at 12:01

2 Answers 2

1

Formula:

To use the textbox value in a formula then access via the linked cell:

If you right click the textbox and inspect properties you can set the linked cell address:

Linked cell

In a formula you can then use the value from the linked cell e.g. = A1 + 1


VBA:

For ActiveX object use

TextBox1.Value

Replace TextBox1 with the appropriate textbox name

Say I had the textbox in "Sheet1" I could see the value with:

Option Explicit
Public Sub test()
    MsgBox Worksheets("Sheet1").TextBox1.Value
End Sub
Sign up to request clarification or add additional context in comments.

Comments

1

Say we have a TextBox that we entered by using Insert > Shape. Insert the following code in a standard module:

Dim ader As Double

Sub TextBox1_Click()
    Dim tb As TextBox
    Set tb = ActiveSheet.TextBoxes("TextBox 1")
    ader = CDbl(tb.Text)
    Application.CalculateFull
End Sub

Public Function valu() As Double
    Application.Volatile
    valu = ader
End Function

Make sure the TextBox has been assigned to the click routine. The event code will update the global variable whenever the TextBox is changed and the TextBox has been clicked. The user defined function will return the current value of the global variable:

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.