Listbox on Userform and a worksheet Excel VBA

DThib

Active Member
Joined
Mar 19, 2010
Messages
464
Office Version
  1. 365
Platform
  1. Windows
Arrgh!,

Last code for this complex thing.
My quandary is using the TextBox (SPR_IDTB) from a userform to populate a ListBox on the userform.
If the matching ID (SPR_IDTB) is found, pull the value in the same row from column A and from Column J. End after searching 1 worksheet. TextBox value is in row B.

Best guess at this point:
Code:
Sub Reslcomm_TB_Change()
   
    Dim c As Range
    Alcomm_LB.Clear
    For Each c In Sheets("Assigned").Range("B:B").End(xlUp)
        If c.Value = SPR_IDTB.Value Then
            Alcomm_LB.AddItem c.Offset(, 12).Value
            Alcomm_LB.AddItem c.Offset(, -1).Value
            Alcomm_LB.List(Alcomm_LB.ListCount - 1, 1) = c.Offset(, 1).Value
        End If
    Next


End Sub
DThib
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
So are you saying the code your showing is not working?
Looks like to me it should work.

Not sure why you have this line of code:
Alcomm_LB.List(Alcomm_LB.ListCount - 1, 1) = c.Offset(, 1).Value
 
Upvote 0
The start of the loop should be
Code:
    For Each c In Sheets("Assigned").Range("B2", Sheets("Assigned").Range("B" & Rows.Count).End(xlUp))
 
Upvote 0
Yes. The rest of the code pulls data into a worksheet and this will be added to. The textbox looks for the match and fills out other textboxes on the userform.
I am trying to have this value also search the rest of the worksheet and where it finds the text in the textbox it should take the row and grab the value in column A and column K to place in the list box
 
Upvote 0
Also if you just want cols A & J in the listbox, on the same line try
Code:
        If c.Value = SPR_IDTB.Value Then
            Alcomm_LB.AddItem c.Offset(, -1).Value
            Alcomm_LB.List(Alcomm_LB.ListCount - 1, 1) = c.Offset(, 12).Value
        End If
 
Upvote 0
Drats! Foiled again...

It does not work. I am calling this from the larger macro that fills out the textboxes for the current days information.
This would fire next as Call Lister
Does not work.

Code:
Sub Lister()
   
    Dim c As Range
     For Each c In Sheets("Resolved").Range("B2", Sheets("Resolved").Range("B" & Rows.Count).End(xlUp))
        If c.Value = SPR_IDTB.Value Then
            Reslcomm_LB.AddItem c.Offset(, -1).Value
            Reslcomm_LB.List(Reslcomm_LB.ListCount - 1, 1) = c.Offset(, 10).Value


        End If
    Next


End Sub

Help
 
Last edited:
Upvote 0
Forgot to mention,

The listbox (Reslcomm_LB) has columns.
"A" is the fist column.
"J" is the second column.

DThib
 
Upvote 0
I Call Lister and nothing fills the list box when I have set up 3 instances on the worksheet to pull from.
The code does nothing. Compiling shows no fault.
 
Upvote 0
It works now. I had a logic statement stopping it and the beginning of the larger macro.

Thanks Fluff!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top