EnsureVisibel and SetFocus not working

GUY08347

Board Regular
Joined
Jul 3, 2006
Messages
87
hi, i'm on win 7, office 2007
i don't know why but after i show a form (from clicking on a cell in the sheet) i noticed that two lines in the code are not executed.

ADDNew_P_win - is the userform shown (with a listview - LV_clients)

the code is:
Code:
                   For i = 1 To ADDNew_P_win.LV_clients.ListItems.Count
                     If ADDNew_P_win.LV_clients.ListItems.Item(i).Text = Sheets("cliList").Range("b" & p).Text And _
                       ADDNew_P_win.LV_clients.ListItems.Item(i).SubItems(1) = Sheets("cliList").Range("c" & p).Text Then
                        ADDNew_P_win.LV_clients.ListItems.Item(i).Selected = True
                        
                            ADDNew_P_win.Lab_selected_client.Caption = Sheets("cliList").Range("l" & p).Value
                            ADDNew_P_win.Lab_selected_client_index.Caption = i
                        Exit For
                     End If
                  Next
                  ADDNew_P_win.LV_clients.ListItems.Item(i).EnsureVisible
                  ADDNew_P_win.LV_clients.SetFocus
                  '--------------------------------------------------------
                 .Height = 333: .Show

the lines are:
Code:
                  ADDNew_P_win.LV_clients.ListItems.Item(i).EnsureVisible
                  ADDNew_P_win.LV_clients.SetFocus
verything else works fine.
why does it happen? i can't think of anything...
thanks!.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,224,606
Messages
6,179,866
Members
452,948
Latest member
UsmanAli786

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