ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combo Box code (https://www.excelbanter.com/excel-programming/302031-combo-box-code.html)

alex

Combo Box code
 
My app is not working stable I suspect the following code
I'm using for combobox.

Private Sub ComboBox1_Change()

On Error GoTo ComboBox1_Change_Err
Me.ComboBox1.ListFillRange = "R3:R97"
With Worksheets("Legend").Range("a3:a448")
.Borders.LineStyle = xlLineStyleNone
.Borders.ColorIndex = 2
.Borders.Weight = xlThin
Set c = .Find(ComboBox1.Value,
LookIn:=xlValues)

c.Borders.LineStyle = xlDouble
c.Borders.Weight = xlThick
c.Borders.Color = RGB(255, 0, 0)
c.Activate

End With
Application.ScreenUpdating = True


ComboBox1_Change_exit:
Exit Sub
ComboBox1_Change_Err:
MsgBox Error
Resume ComboBox1_Change_exit

End Sub

Could anybody look at this and say whether it's Ok to be
used for combobox?

Thanks



Bob Phillips[_6_]

Combo Box code
 
Might help to know how it is not working.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Alex" wrote in message
...
My app is not working stable I suspect the following code
I'm using for combobox.

Private Sub ComboBox1_Change()

On Error GoTo ComboBox1_Change_Err
Me.ComboBox1.ListFillRange = "R3:R97"
With Worksheets("Legend").Range("a3:a448")
.Borders.LineStyle = xlLineStyleNone
.Borders.ColorIndex = 2
.Borders.Weight = xlThin
Set c = .Find(ComboBox1.Value,
LookIn:=xlValues)

c.Borders.LineStyle = xlDouble
c.Borders.Weight = xlThick
c.Borders.Color = RGB(255, 0, 0)
c.Activate

End With
Application.ScreenUpdating = True


ComboBox1_Change_exit:
Exit Sub
ComboBox1_Change_Err:
MsgBox Error
Resume ComboBox1_Change_exit

End Sub

Could anybody look at this and say whether it's Ok to be
used for combobox?

Thanks





alex

Combo Box code
 
Sometimes, I'm getting an empty combobox.

-----Original Message-----
Might help to know how it is not working.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Alex" wrote in

message
...
My app is not working stable I suspect the following

code
I'm using for combobox.

Private Sub ComboBox1_Change()

On Error GoTo ComboBox1_Change_Err
Me.ComboBox1.ListFillRange = "R3:R97"
With Worksheets("Legend").Range("a3:a448")
.Borders.LineStyle = xlLineStyleNone
.Borders.ColorIndex = 2
.Borders.Weight = xlThin
Set c = .Find(ComboBox1.Value,
LookIn:=xlValues)

c.Borders.LineStyle = xlDouble
c.Borders.Weight = xlThick
c.Borders.Color = RGB(255, 0, 0)
c.Activate

End With
Application.ScreenUpdating = True


ComboBox1_Change_exit:
Exit Sub
ComboBox1_Change_Err:
MsgBox Error
Resume ComboBox1_Change_exit

End Sub

Could anybody look at this and say whether it's Ok to be
used for combobox?

Thanks




.


Bob Phillips[_6_]

Combo Box code
 
Could it be that different sheets are being activated and the line
Me.ComboBox1.ListFillRange = "R3:R97"
would sometimes refer to a blank range?

This seems superfluous, just set it in design, or in the form activate, not
in every combo change.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Alex" wrote in message
...
Sometimes, I'm getting an empty combobox.

-----Original Message-----
Might help to know how it is not working.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Alex" wrote in

message
...
My app is not working stable I suspect the following

code
I'm using for combobox.

Private Sub ComboBox1_Change()

On Error GoTo ComboBox1_Change_Err
Me.ComboBox1.ListFillRange = "R3:R97"
With Worksheets("Legend").Range("a3:a448")
.Borders.LineStyle = xlLineStyleNone
.Borders.ColorIndex = 2
.Borders.Weight = xlThin
Set c = .Find(ComboBox1.Value,
LookIn:=xlValues)

c.Borders.LineStyle = xlDouble
c.Borders.Weight = xlThick
c.Borders.Color = RGB(255, 0, 0)
c.Activate

End With
Application.ScreenUpdating = True


ComboBox1_Change_exit:
Exit Sub
ComboBox1_Change_Err:
MsgBox Error
Resume ComboBox1_Change_exit

End Sub

Could anybody look at this and say whether it's Ok to be
used for combobox?

Thanks




.





All times are GMT +1. The time now is 09:47 AM.

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