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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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