plss help...

ganesh_05

New Member
Joined
Aug 11, 2005
Messages
43
hii frnds,

I am a facing a problem with data handling in worksheets. I have some data like this...

In column A1, i have different variables like p1,p1,p1,p1,p1,p1,p2,p2,p2,p3,p3,p3,p4,p4,etc.

and the data related to p1(in cell A1) is from B1 to Z1, p1(cell A2) is from B2 to Z2, p1(cell A3) is from B3 to Z3 etc.

so i want to show all the data related to P1 (in all the rows) in a listbox using rowsource property. And the same i want to do it for p2, p3 etc.

how to do this??

Thanks in advance...

Ganesh.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I don't know how many rows p1 occupies... how many rows p2 occupies... so cannot fix the rowsource property in that sense...
 
Upvote 0
what about the following code??

Set range1 = Range("B1:B2")

Sheets("f_Output").Activate
With ActiveSheet

For Each cell In .Range(Range("A1"), Range("A65536").End(xlUp))
If cell.Value = ComboBox1.Text Then
Set range2 = Range(cell.Offset(0, 1), cell.Offset(0, 50))
Set range1 = Union(range1, range2)
End If
Next cell

End With

'listrange = range1

ListBox1.RowSource = range1
 
Upvote 0
then the rowsource should be B1:Z3

but i don't know whether P1 will be in 3 rows or 4 rows or 5 rows... its unknown parameter... i mean rownumber is a variable...

and is it possible to make column number also variable?? i mean wht if its not Zth column.. may be some other column that is not known a priori...
 
Upvote 0
assuming the listbox on the sheet
Code:
Private Sub ComboBox1_Change()
Dim r1 As Range, r2 As Range, txt As String
With Me.ComboBox1
    Set r1 = Columns(1).Find(.Text, Cells(Rows.Count, 1), , xlWhole, , xlNext)
    If r1 Is Nothing Then Exit Sub
    Set r2 = Columns(1).Find(.Text, Cells(1, 1), , xlWhole, , xlPrevious)
    If r2 Is Nothing Then Exit Sub
    txt = Range("b" & r1.Row).Resize(r2.Row - r1.Row + 1, 25).Address
End With
Me.ListBox1.ListFillRange = txt
End Sub
 
Upvote 0
hii jindon,

its saying syntax error at...

Set r1 = Columns(1).Find(.Text, Cells(Rows.Count, 1), , xlWhole, , xlNext)
If r1 Is Nothing Then Exit Sub
Set r2 = Columns(1).Find(.Text, Cells(1, 1), , xlWhole, , xlPrevious)
If r2 Is Nothing Then Exit Sub
txt = Range("b" & r1.Row).Resize(r2.Row - r1.Row + 1, 25).Address

what mite be the reason ?
 
Upvote 0
Are those controls on the sheet or userform?

I need to go out now, so the reply will be tomorrow.
 
Upvote 0
hi

cud solve my problem... but now a new problem...

whtever range i specify to my listbox to popup... i want the same headers for every range it displays... how to fix the headers??

i want the following series in column headers...

T1 T2 T3 T4 T5 T6 etc....

how to do this??
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,438
Members
448,897
Latest member
dukenia71

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