+ Reply to Thread
Results 1 to 12 of 12

Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

Hybrid View

breadwinner Vlookup through 3 sheets from... 06-05-2014, 05:42 AM
breadwinner Re: Vlookup through 3 sheets... 06-05-2014, 01:57 PM
Tinbendr Re: Vlookup through 3 sheets... 06-06-2014, 10:57 AM
breadwinner Re: Vlookup through 3 sheets... 06-07-2014, 04:10 AM
breadwinner Re: Vlookup through 3 sheets... 06-09-2014, 07:39 AM
Tinbendr Re: Vlookup through 3 sheets... 06-10-2014, 10:06 AM
breadwinner Re: Vlookup through 3 sheets... 06-10-2014, 12:29 PM
Tinbendr Re: Vlookup through 3 sheets... 06-10-2014, 01:41 PM
breadwinner Re: Vlookup through 3 sheets... 06-10-2014, 09:16 PM
Tinbendr Re: Vlookup through 3 sheets... 06-10-2014, 09:36 PM
breadwinner Re: Vlookup through 3 sheets... 06-11-2014, 03:04 AM
Winon Re: Vlookup through 3 sheets... 06-11-2014, 05:17 AM
  1. #1
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    Dear Experts

    I have set of data base in 3 sheets in wb and VBA Userform built with multiple textboxes and cmd button i want retrieve data from 3 sheets(Dispatch12,Closed11,cancel2) ,once click the cmd button then get result in to all textboxes through one lookup values from different sheets range for particular wizard field)

    1.Order No column is Lookup_value,
    2. Dispatch & Closed & Cancel is Table Array.
    3. Column In caption for every Wizard ( Dispatch & Closed & Cancel)

    E.g find the attachment of example wb

    find the report wb attachment

    thanks
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    Re: Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    any experts can help on this??

  3. #3
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    You'll have to line up the textbox numbers with the column numbers.
    Private Sub CommandButton1_Click()
    Dim Answer As Variant
    Dim A As Long
    Dim tmp
        Answer = TextBox1.Value
        If Answer <> "" Then
            For A = 2 To 37
            '=VLOOKUP(B2, B2:AQ165000,2,0)
            tmp = Application.VLookup(Val(Answer), Worksheets("Dispatchcalls").Range("B1:AQ16"), A - 1, False)
                Me.Controls("TextBox" & A).Value = tmp
             'so on and so forth for several other combo- and textboxes
            Next
        End If
    End Sub
    David
    (*) Reputation points appreciated.

  4. #4
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    Re: Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    Dear sir

    Its Lookup range from dispatchcalls sheet only..
    but requirement is Onelookup value is through order no get result in to text from 3 sheets because order no in dispatch reflects into closed and cancel also..

    for e.g Order no 7005230838 is reflect in two dispatch & closedcalls also i want vlookup from dispatch for first 23s textbox then 11 textboxs from closedcalls.
    another example order no 7005233198 is reflect in three sheets i want vlookup from dispatch for first 23s textbox then 11 textboxs from closedcalls. then 2 textbos from cancelcalls..

    find the attachment....
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    Re: Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    any experts would help on this task???
    Last edited by breadwinner; 06-09-2014 at 12:28 PM. Reason: save

  6. #6
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    Now that I've reread the thread, I'm confused.

    Do you want to lookup in the userform and edit the values?

    Or do you want the Report generated?

    Or do you want both?

  7. #7
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    Re: Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    Dear sir

    I want to lookup values in the userform only ? Nothing else

  8. #8
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    I changed the textbox1 to a combobox1. I then create a unique list of the SO#'s and put them into the combobox. It works really well.

    Option Explicit
    Private Sub UserForm_Initialize()
    Dim WS As Worksheet
    Dim Unique As New Collection
    Dim A As Long
    Dim LastRow As Long
    
    Set WS = Worksheets("DispatchCalls")
    
    With WS
        LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
        
        For A = 2 To LastRow
            On Error Resume Next
            Unique.Add CStr(.Range("B" & A)), CStr(A)
            On Error GoTo 0
        Next
    End With
    
        For A = 1 To Unique.Count
            Me.ComboBox1.AddItem Unique(A)
        Next
    End Sub
    
    Private Sub combobox1_change()
    Dim WS As Worksheet
    Dim LastRow As Long
    Dim C As Range
    Dim Answer As Variant
    Dim A As Long
    Dim Ctrl As Control
    
    'Clear all textboxes
    For Each Ctrl In Me.Controls
        Select Case TypeName(Ctrl)
        Case "TextBox"
            Ctrl.Value = ""
        End Select
    Next
    
        Answer = Me.ComboBox1
        If Answer <> "" Then
            'Dispatch
            Set WS = Worksheets("DispatchCalls")
            
            With WS
                LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
                With .Range("B2:B" & LastRow)
                    Set C = .Find(Answer, , xlValues)
                    If Not C Is Nothing Then
                        'Header
                        Me.TextBox2 = C.Offset(, -1)
                        Me.TextBox3 = C.Offset(, Range("C1").Column - 2)
                        Me.TextBox4 = C.Offset(, Range("D1").Column - 2)
                        Me.TextBox5 = C.Offset(, Range("E1").Column - 2)
                        Me.TextBox6 = C.Offset(, Range("G1").Column - 2)
                        Me.TextBox7 = C.Offset(, Range("H1").Column - 2)
                        Me.TextBox8 = C.Offset(, Range("J1").Column - 2)
                        Me.TextBox9 = C.Offset(, Range("K1").Column - 2)
                        Me.TextBox10 = C.Offset(, Range("N1").Column - 2)
                        Me.TextBox11 = C.Offset(, Range("U1").Column - 2)
                        
                        'Dispatch Calls
                        Me.TextBox12 = C.Offset(, Range("Y1").Column - 2)
                        Me.TextBox13 = C.Offset(, Range("Z1").Column - 2)
                        Me.TextBox14 = C.Offset(, Range("AA1").Column - 2)
                        Me.TextBox15 = C.Offset(, Range("AB1").Column - 2)
                        Me.TextBox16 = C.Offset(, Range("AC1").Column - 2)
                        Me.TextBox17 = C.Offset(, Range("Y1").Column - 2)
                        Me.TextBox18 = C.Offset(, Range("AD1").Column - 2)
                        Me.TextBox19 = C.Offset(, Range("AE1").Column - 2)
                        Me.TextBox20 = C.Offset(, Range("AF1").Column - 2)
                        Me.TextBox21 = C.Offset(, Range("AG1").Column - 2)
                        Me.TextBox22 = C.Offset(, Range("AI1").Column - 2)
                        Me.TextBox23 = C.Offset(, Range("AJ1").Column - 2)
                        Me.TextBox24 = C.Offset(, Range("AK1").Column - 2)
                    End If
                End With
            End With
                
            Set WS = Worksheets("ClosedCalls")
            
            With WS
                LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
                With .Range("B2:B" & LastRow)
                    Set C = .Find(Answer, , xlValues)
                    If Not C Is Nothing Then
                        'Closed Calls
                        Me.TextBox25 = C.Offset(, Range("AL1").Column - 2)
                        Me.TextBox26 = C.Offset(, Range("AM1").Column - 2)
                        Me.TextBox27 = C.Offset(, Range("AN1").Column - 2)
                        Me.TextBox28 = C.Offset(, Range("AO1").Column - 2)
                        Me.TextBox29 = C.Offset(, Range("AP1").Column - 2)
                        Me.TextBox30 = C.Offset(, Range("AQ1").Column - 2)
                        Me.TextBox31 = C.Offset(, Range("AR1").Column - 2)
                        Me.TextBox32 = C.Offset(, Range("AS1").Column - 2)
                        Me.TextBox33 = C.Offset(, Range("AT1").Column - 2)
                        Me.TextBox34 = C.Offset(, Range("AV1").Column - 2)
                        Me.TextBox35 = C.Offset(, Range("AW1").Column - 2)
                        
                    End If
                End With
            End With
        
            Set WS = Worksheets("CancelCalls")
            
            With WS
                LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
                With .Range("B2:B" & LastRow)
                    Set C = .Find(Answer, , xlValues)
                    If Not C Is Nothing Then
                        'Cancel Calls
                        Me.TextBox36 = C.Offset(, Range("AI1").Column - 2)
                        Me.TextBox37 = C.Offset(, Range("AK1").Column - 2)
                    End If
                End With
            End With
        End If
    End Sub
    Last edited by Tinbendr; 06-11-2014 at 07:22 AM. Reason: code correction

  9. #9
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    Re: Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    Dear sir

    I inserted combobox1 but Data Not vlookup into textboxes through lookup values?

  10. #10
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    I just learned something new. If the column width isn't wide enough, Excel will show the value as scientific notation and Range Find WILL NOT FIND the actual value.

    See the attached.
    Attached Files Attached Files
    Last edited by Tinbendr; 06-11-2014 at 07:15 AM.

  11. #11
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    Re: Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    Dear sir

    Fantastic !!! No words to express about ur patience,completion !! Thanks for spend your valuable time for me???

  12. #12
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Vlookup through 3 sheets from one lookup value result in all textbox in userform vba

    @ Tinbendr,

    Good work!

    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Using userform textbox value in code result
    By Sc0tt1e in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-29-2013, 10:18 AM
  2. [SOLVED] VBA UserForm - Have entry in TextBox fill Another TextBox by VLOOKUP
    By msquared99 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-26-2012, 10:24 PM
  3. Use textbox input and VLookup to update another textbox on same userform
    By gcoug in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-22-2011, 10:39 AM
  4. Display result in userform (vba) textbox
    By ilovelagar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-18-2009, 04:47 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1