• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

A quick question: how to populate value in textbox after filtering data

Mr.Karr

Member
Hello

Can anyone please provide a code snippet to populate visible cell in textbox1 ?

In detail: I have an userform by which I filter data using various criteria. As soon as user hits search, it looks for matching records and filters out. Now I need to Initialize userform with cell value against labels.

Below works for a combobox
Code:
Private Sub UserForm_Initialize()
    'For i = 1 To Sheets("Sheet1").Cells(1, 1).SpecialCells(xlLastCell).Row
        'If Sheets("Sheet1").Cells(i, 1) <> "" Then
            TestForm.Combotest.AddItem (Cells(i, 1))
        'End If
    'Next
   
End Sub

But I need a code snippet for a textbox. Please help.

Thanks in advance.
 
Hi Mr.Karr
Do you mean like:

Code:
Testform.Texttest.value = sheets("Sheet1").cells(i, 1).text

I'm guessing your textbox is called Texttest.

I'm not sure I fully understood what you meant, but if this is what you wanted, glad to help!

Kind regards,
Stevie
 
Code:
TextBox4.Value = Range("B" & Selection.Row).Value
TextBox7.Value = Range("C" & Selection.Row).Value
TextBox10.Value = Range("J" & Selection.Row).Value

this should be it.
But this is picking up labels. Can anyone please help to get the next value or any offset help please ?
Much appreciated
 
Hi Mr.Karr
Did you rename the textbox and change the references in the code I gave?
Code:
Testform.TextBox4.value = Range("B" & Selection.Row).text
The above works for me, and should work for you assuming your userform is called 'Testform', and you have the correct cell selected so that your 'selection.row' returns a value.
 
Back
Top