PDA

View Full Version : Solved: How to get data from TextBox?



genracela
05-26-2010, 11:11 PM
I've a formula that will get the value from my textbox in Column F6
And I think I'm not doing correctly.

The textbox is in column F6
Please help!

Thanks!

Option Explicit
Sub Search()
If UCase(Range("F6").Value) <> "ALL" Then
TextBox1.Value.Range("E9").Formula = "=IF(ISERROR(INDEX(Data!$A:$A,MATCH($F$6,Data!$E:$E,0))),""No Records"",INDEX(Data!$A:$A,MATCH($F$6,Data!$E:$E,0)))"
TextBox1.Value.Range("F9").Formula = "=IF(ISERROR(INDEX(Data!$B:$B,MATCH($F$6,Data!$E:$E,0))),""No Records"",INDEX(Data!$B:$B,MATCH($F$6,Data!$E:$E,0)))"
TextBox1.Value.Range("G9").Formula = "=IF(ISERROR(INDEX(Data!$C:$C,MATCH($F$6,Data!$E:$E,0))),""No Records"",INDEX(Data!$C:$C,MATCH($F$6,Data!$E:$E,0)))"
End If
End Sub

Bob Phillips
05-27-2010, 12:58 AM
Textboxes cannot be in a column as they are not part of a worksheet. YOu can place them so that they overlay a column but that is a different matter, they are separate from a worksheet.

Explain whatyou are trying to do, and what sort of textbox it is, drawing box or control toolbox textbox.

genracela
05-27-2010, 01:06 AM
It's an active x textbox in F6. Actually the formula can function if the textbox is not there. But since I want to have a textbox in F6, I put one.

But anyway, my idea is just to calculate the formula, so what I just did is:
Private Sub TextBox1_Change()
Range("A2").Value = TextBox1.Text
End Sub

Then just changed F6 to A2 in my in my formula:

"=IF(ISERROR(INDEX(Data!$A:$A,MATCH($F$6,Data!$E:$E,0))),""No Records"",INDEX(Data!$A:$A,MATCH($F$6,Data!$E:$E,0)))"

mdmackillop
05-27-2010, 09:06 AM
One of the Text Box properties is Linked Cell. Set that to a cell address (commonly hidden by the text box) and refer to that as usual.

genracela
05-27-2010, 07:28 PM
Thanks!