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
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
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:
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
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: