ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   populate multicolumn listbox? (https://www.excelbanter.com/excel-programming/325968-populate-multicolumn-listbox.html)

Alen32

populate multicolumn listbox?
 
I got thics code here but I can't insert results in listbox.

With userform1
if .optionButton1 then
sOne = "Horse"
else
sOne = "Pig"
end if
if .optionButton3 then
sTwo = "Danish"
else
sTwo = "Foreign"
end if
sThree = .Textbox1.Text
End With
With Worksheets(1).Cells
Set c = .Find(sOne, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
if application.countif(c.EntireRow,"*" & sTwo & "*") and _
application.Countif(c.EntireRow,"*" & sThree & "*") then
' add row to listbox
end if
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With



Tom Ogilvy

populate multicolumn listbox?
 
You just said you wanted to add the row to the listbox. That is
significantly vague. Obviously you don't want to add 256 cells to the
listbox. so what do you want to do? What cells in the found code do you
want to add to the listbox.

--
Regards,
Tom Ogilvy


"Alen32" wrote in message
lkaboutsoftware.com...
I got thics code here but I can't insert results in listbox.

With userform1
if .optionButton1 then
sOne = "Horse"
else
sOne = "Pig"
end if
if .optionButton3 then
sTwo = "Danish"
else
sTwo = "Foreign"
end if
sThree = .Textbox1.Text
End With
With Worksheets(1).Cells
Set c = .Find(sOne, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
if application.countif(c.EntireRow,"*" & sTwo & "*") and _
application.Countif(c.EntireRow,"*" & sThree & "*") then
' add row to listbox
end if
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With





Alen32

populate multicolumn listbox?
 
like her:
.ListBox1.AddItem cell.Value
.ListBox1.List(.ListBox1.ListCount - 1, 1) _
= cell.Offset(0, 2).Value
.ListBox1.List(.ListBox1.ListCount - 1, 2) _
= cell.Offset(0, 5).Value



Tom Ogilvy

populate multicolumn listbox?
 
With userform1
if .optionButton1 then
sOne = "Horse"
else
sOne = "Pig"
end if
if .optionButton3 then
sTwo = "Danish"
else
sTwo = "Foreign"
end if
sThree = .Textbox1.Text
End With
With Worksheets(1).Cells
Set c = .Find(sOne, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
if application.countif(c.EntireRow,"*" & sTwo & "*") and _
application.Countif(c.EntireRow,"*" & sThree & "*") then
Userform1.ListBox1.AddItem c.Value
Userform1.ListBox1.List( _
Userform1.ListBox1.ListCount - 1, 1) _
= c.Offset(0, 2).Value
Userform1.ListBox1.List( _
Userform1.ListBox1.ListCount - 1, 2) _
= c.Offset(0, 5).Value
end if
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

Assuming the cell you want to base your offset on is the the one containing
pig or horse

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
You just said you wanted to add the row to the listbox. That is
significantly vague. Obviously you don't want to add 256 cells to the
listbox. so what do you want to do? What cells in the found code do you
want to add to the listbox.

--
Regards,
Tom Ogilvy


"Alen32" wrote in message
lkaboutsoftware.com...
I got thics code here but I can't insert results in listbox.

With userform1
if .optionButton1 then
sOne = "Horse"
else
sOne = "Pig"
end if
if .optionButton3 then
sTwo = "Danish"
else
sTwo = "Foreign"
end if
sThree = .Textbox1.Text
End With
With Worksheets(1).Cells
Set c = .Find(sOne, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
if application.countif(c.EntireRow,"*" & sTwo & "*") and _
application.Countif(c.EntireRow,"*" & sThree & "*") then
' add row to listbox
end if
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With







Alen32

populate multicolumn listbox?
 
fantastic its working!!!!
Thanks Tom!!



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

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