Consulting

Results 1 to 5 of 5

Thread: Solved: How to get data from TextBox?

  1. #1

    Solved: How to get data from TextBox?

    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!

    [VBA]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[/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    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:
    [VBA]Private Sub TextBox1_Change()
    Range("A2").Value = TextBox1.Text
    End Sub[/VBA]

    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)))"

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •