Row number not shown in listbox advice

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I use the code below to populate a listbox
The issue i have is that the row number isnt shown in the listbox.
Clicking on a listbox entry i am taken to that customer.
There are no run time error etc.

Only issue is that the row number isnt being shown.

Below is the code taken from one textbox.

Can you see an issue as to why this is.
Thanks

Private Sub TextBoxCUSTOMER_Change()
TextBoxCUSTOMER = UCase(TextBoxCUSTOMER)
Dim r As Range, f As Range, cell As String, added As Boolean
Dim sh As Worksheet

Set sh = Sheets("DETAILS")
sh.Select
With ListBox1
.Clear
.ColumnCount = 7
.ColumnWidths = "180;150;150;100;80;60;10"
If TextBoxCUSTOMER.Value = "" Then Exit Sub
Set r = Range("A2", Range("A" & Rows.Count).End(xlUp))
Set f = r.Find(TextBoxCUSTOMER.Value, LookIn:=xlValues, lookat:=xlPart)
If Not f Is Nothing Then
cell = f.Address
Do
added = False
For i = 0 To .ListCount - 1
Select Case StrComp(.List(i), f.Value, vbTextCompare)
Case 0, 1
.AddItem f.Value, i
.List(i, 1) = f.Offset(, 1).Value
.List(i, 2) = f.Offset(, 2).Value
.List(i, 3) = f.Offset(, 3).Value
.List(i, 4) = f.Offset(, 6).Value
.List(i, 5) = f.Offset(, 7).Value
.List(i, 7) = f.Row
added = True
Exit For
End Select
Next
If added = False Then
.AddItem f.Value
.List(.ListCount - 1, 1) = f.Offset(, 1).Value
.List(.ListCount - 1, 2) = f.Offset(, 2).Value
.List(.ListCount - 1, 3) = f.Offset(, 3).Value
.List(.ListCount - 1, 4) = f.Offset(, 6).Value
.List(.ListCount - 1, 5) = f.Offset(, 7).Value
.List(.ListCount - 1, 7) = f.Row
End If
Set f = r.FindNext(f)
Loop While Not f Is Nothing And f.Address <> cell
TextBoxSearch = UCase(TextBoxSearch)
.TopIndex = 0
Else
MsgBox "NO CUSTOMER WAS FOUND", vbCritical, "CLONING INFORMATION MESSAGE"
TextBoxCUSTOMER.Value = ""
TextBoxCUSTOMER.SetFocus
End If
End With
End Sub
Rich (BB code):
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi
try changing ColumnCount line value to 8 and see if resolves your issue

Rich (BB code):
.ColumnCount = 8

Dave
 
Upvote 0
Solution

Forum statistics

Threads
1,224,829
Messages
6,181,218
Members
453,024
Latest member
Wingit77

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