seelect row using list box

isildad

Active Member
Joined
Sep 22, 2004
Messages
325
this code in my list box selects row2
Need to change the code to select the row corresponding to my selection in the list box.
Code:
Sub ListBox1_Change()
Rows("2:2").Select
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Code:
Private Sub ListBox1_Change()
With ListBox1
     If .Value <> "" Then Rows(.Value).Select
End With
End Sub
 
Upvote 0
Thx to both of you.
should have said that listbox is from Forms & not Control Toolbox
Most important the value is sometimes text sometimes numeral
sorry for this,

BTW both codes OK with listbox from Control toolbox BUT work only with numeral values and not text
Thx

Edit: Prefer Control toolbox list box now ,,, just need help with error if value is text
Code OK with numeric values
 
Upvote 0
try
Code:
Private Sub ListBox1_Change()
With ListBox1
     If Val(.Value) > 0 Then Rows(.Value).Select
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,315
Messages
6,165,303
Members
451,950
Latest member
WH2000

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