ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to add itemfrom a worksheet to a Listbox (https://www.excelbanter.com/excel-programming/427050-how-add-itemfrom-worksheet-listbox.html)

Ayo

How to add itemfrom a worksheet to a Listbox
 
I have a form with a 2 column listbox, and a worksheet with a two column
list. I want to add items from the worksheet list to the listbox based on
specific conditions. For example:

For Each c5 In dbeWS.Range("B2:B" & rngSAPlines).Cells
If c5.Value = ufrmsiteInfo.cmbSiteID.Text And c5.Offset(0,1).Value
ufrmsiteInfo.txtbox3.Text And c5.Offset(0, 4).Value = False Then
ufrmsiteInfo.ListBox4.AddItem "worksheet row here"
End If
Next c5

Rick Rothstein

How to add itemfrom a worksheet to a Listbox
 
I'm not sure what your question is. Is it that you want to know how to get
the "worksheet row here"? If so, try using c5.Row in place of your quote.

--
Rick (MVP - Excel)


"Ayo" wrote in message
...
I have a form with a 2 column listbox, and a worksheet with a two column
list. I want to add items from the worksheet list to the listbox based on
specific conditions. For example:

For Each c5 In dbeWS.Range("B2:B" & rngSAPlines).Cells
If c5.Value = ufrmsiteInfo.cmbSiteID.Text And c5.Offset(0,1).Value
ufrmsiteInfo.txtbox3.Text And c5.Offset(0, 4).Value = False
Then
ufrmsiteInfo.ListBox4.AddItem "worksheet row here"
End If
Next c5



Ayo

How to add itemfrom a worksheet to a Listbox
 
Not the whole row just the two cells next to each other. I have a 2 column
table in the worksheet i.e., Range("B2:C391") so,
ufrmsiteInfo.ListBox4.AddItem "worksheet row here"

worksheet row here could be B3 and C3


"Rick Rothstein" wrote:

I'm not sure what your question is. Is it that you want to know how to get
the "worksheet row here"? If so, try using c5.Row in place of your quote.

--
Rick (MVP - Excel)


"Ayo" wrote in message
...
I have a form with a 2 column listbox, and a worksheet with a two column
list. I want to add items from the worksheet list to the listbox based on
specific conditions. For example:

For Each c5 In dbeWS.Range("B2:B" & rngSAPlines).Cells
If c5.Value = ufrmsiteInfo.cmbSiteID.Text And c5.Offset(0,1).Value
ufrmsiteInfo.txtbox3.Text And c5.Offset(0, 4).Value = False
Then
ufrmsiteInfo.ListBox4.AddItem "worksheet row here"
End If
Next c5





All times are GMT +1. The time now is 01:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com