ListBox selection selects wrong customer on worksheet

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I am using the code as shown.

I populate the Listbox & i then make a selection.
I should then be on the worksheet looking at the customer that i selected from the Listbox but this isnt the case.

Example of whats happening.
The listbox shows 4 customers of which are ABCD
I select A but i am taken C
I then run the code again to populate the Listbox.
I then select A again but taken to D

As you would expect whatever you select you should then be taken to that customer.
Also when the customer is selected on the worksheet it selects the cell in column I but i wish to have it select column A
Do you see what is causing this please



Rich (BB code):
Private Sub ListBox1_Click()
With ThisWorkbook.Worksheets("DATABASE")
Dim data As Variant

    data = .Range("I6:I" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With
  
   Cells.Find(What:=ListBox1.Value, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False).Activate
        
   Unload ProgrammerForm
   
   answer = MsgBox("OPEN CUSTOMERS FILE IN MAIN DATABASE ?", vbYesNo + vbInformation, "OPEN DATABASE MESSAGE")
   If answer = vbYes Then
   
   Database.LoadData Sheets("DATABASE"), Selection.Row
   
 Else
 Unload ProgrammerForm
 End If
 
End Sub
 
Now working thanks.

To be honest i thought you had put that piece of code in the wriong place.

Many thanks
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Now working thanks.

To be honest i thought you had put that piece of code in the wriong place.

Many thanks

The instruction given was very clear
Note the variable at the top of the codes – this variable MUST be placed at very TOP of your userforms code page OUTSIDE any procedure.

If you are unsure about any direction given you should come back and ask for further explanation - making unilateral changes & then reporting code is not working, can be tad frustrating for those trying to assist.

Glad issue now resolved but having seen your project, I note that other userforms (of which there are many) use the very solution I have just assisted you with - As friendly advice, when you copy code that you know works to re-use in another project, ensure that you copy it all - you can save yourself a lot of time and anguish.

Appreciate your feedback

Dave
 
Upvote 0

Forum statistics

Threads
1,215,103
Messages
6,123,110
Members
449,096
Latest member
provoking

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