ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combobox run time error (https://www.excelbanter.com/excel-programming/300568-combobox-run-time-error.html)

Oreg[_18_]

Combobox run time error
 
Hello. Back again with another trouble. I keep getting a run tim
error 13 when I arrow down the list that combobox4 displays when th
form is opened. Is there some code I can enter that once I arrow dow
to an empty cell, combobox will go back to the top of the list i
column D? Thanks in advance!


Private Sub combobox4_Click()
Dim dt As Long
With crit
If .ComboBox4.ListIndex = -1 Then Exit Sub
dt = ComboBox4.Value
For Each Cell In Worksheets("METRO").Range("D1:D200")
If Cell.Text = dt Then
TextBox1.Value = Cell.Offset(0, 3).Text
TextBox2.Value = Cell.Offset(0, -2).Text
TextBox3.Value = Cell.Offset(0, 30).Text
TextBox4.Value = Cell.Offset(0, 23).Text
TextBox5.Value = Cell.Offset(0, -1).Text
TextBox6.Value = Cell.Offset(0, 1).Text
TextBox7.Value = Cell.Offset(0, 2).Text
TextBox8.Value = Cell.Offset(0, 4).Text
TextBox9.Value = Cell.Offset(0, 6).Text
TextBox10.Value = Cell.Offset(0, 7).Text
TextBox11.Value = Cell.Offset(0, 8).Text
TextBox12.Value = Cell.Offset(0, 16).Text
TextBox13.Value = Cell.Offset(0, 9).Text
TextBox14.Value = Cell.Offset(0, 31).Text
TextBox15.Value = Cell.Offset(0, 32).Text
TextBox16.Value = Cell.Offset(0, 26).Text
TextBox17.Value = Cell.Offset(0, 27).Text
TextBox18.Value = Cell.Offset(0, 5).Text

End If
Next
End With
End Su

--
Message posted from http://www.ExcelForum.com


Vasant Nanavati

Combobox run time error
 
Not sure I understand the problem. Have you tried using the Change event
rather than the Click event?

--

Vasant

"Oreg " wrote in message
...
Hello. Back again with another trouble. I keep getting a run time
error 13 when I arrow down the list that combobox4 displays when the
form is opened. Is there some code I can enter that once I arrow down
to an empty cell, combobox will go back to the top of the list in
column D? Thanks in advance!


Private Sub combobox4_Click()
Dim dt As Long
With crit
If .ComboBox4.ListIndex = -1 Then Exit Sub
dt = ComboBox4.Value
For Each Cell In Worksheets("METRO").Range("D1:D200")
If Cell.Text = dt Then
TextBox1.Value = Cell.Offset(0, 3).Text
TextBox2.Value = Cell.Offset(0, -2).Text
TextBox3.Value = Cell.Offset(0, 30).Text
TextBox4.Value = Cell.Offset(0, 23).Text
TextBox5.Value = Cell.Offset(0, -1).Text
TextBox6.Value = Cell.Offset(0, 1).Text
TextBox7.Value = Cell.Offset(0, 2).Text
TextBox8.Value = Cell.Offset(0, 4).Text
TextBox9.Value = Cell.Offset(0, 6).Text
TextBox10.Value = Cell.Offset(0, 7).Text
TextBox11.Value = Cell.Offset(0, 8).Text
TextBox12.Value = Cell.Offset(0, 16).Text
TextBox13.Value = Cell.Offset(0, 9).Text
TextBox14.Value = Cell.Offset(0, 31).Text
TextBox15.Value = Cell.Offset(0, 32).Text
TextBox16.Value = Cell.Offset(0, 26).Text
TextBox17.Value = Cell.Offset(0, 27).Text
TextBox18.Value = Cell.Offset(0, 5).Text

End If
Next
End With
End Sub


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 08:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com