ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reference A Combobox On The First page. (https://www.excelbanter.com/excel-programming/355233-reference-combobox-first-page.html)

Sean[_14_]

Reference A Combobox On The First page.
 
I have a combobox ( named "ddCity" ) placed on the first page of a
worksheet. On the Activate event of ANY other worksheet, I want to
display a polite message indicating they need to choose a city, first.

How do I reference the combobox?

Something like...

If isnull(Worksheets("Main").ComboBox("ddCity").value ) = True Then
MsgBox "Please Choose A City."
Worksheets("Main").ComboBox("ddCity").Select
Exit Sub
End If


Tom Ogilvy

Reference A Combobox On The First page.
 
Private Sub Worksheet_Activate()
If Worksheets("Main").ddCity.Value = "" Then
MsgBox "Please Choose A City."
Worksheets("Main").Select
Worksheets("Main").ddCity.Activate
Exit Sub
End If

End Sub


This assumes ddcity is the name of an activeX combobox from the control
toolbox toolbar and the name ddcity is set in the name property when you
right click on it in design mode and select properties.


Tested and worked for me.
--
Regards,
Tom Ogilvy



"Sean" wrote in message
ups.com...
I have a combobox ( named "ddCity" ) placed on the first page of a
worksheet. On the Activate event of ANY other worksheet, I want to
display a polite message indicating they need to choose a city, first.

How do I reference the combobox?

Something like...

If isnull(Worksheets("Main").ComboBox("ddCity").value ) = True Then
MsgBox "Please Choose A City."
Worksheets("Main").ComboBox("ddCity").Select
Exit Sub
End If




JohnELaw

Reference A Combobox On The First page.
 
Thank you very much! That works perfect!



All times are GMT +1. The time now is 01:16 AM.

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