ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ComboBox populating problem (https://www.excelbanter.com/excel-programming/335908-combobox-populating-problem.html)

Werner[_33_]

ComboBox populating problem
 

Hi,

I have 3 combobox. When I import values in my form, it copies in th
linked cells the past choices I made in my combobox the last time
imported my data. when I have finished with my work in my form, I hav
an update macro that sends back to the source table the values that ar
in my linked cells. But When I do so, it changes the values in my linke
cells into another one in the combobox and it saves the wrong choice. I
always come back to the same wrong choice.

I think the problem is when I change the source sheet and come back t
the Form sheet, it launches again the code to populate the comboboxes
Is there a way to execute the populating code of the combobox only a
the opening of the workbook?
Thx!

Werner

This is the populating code in the working place in VBA :


Code
-------------------


Public Sub Worksheet_Activate()
With ComboBox1
.Clear

.AddItem "Nord"
.AddItem "Lebourgneuf"
.AddItem "Henri IV/Blvd Hamel"
.AddItem "Ste-Foy Périphérie"
.AddItem "Blvd Laurier"
.AddItem "Haute-Ville/Colline Parlementaire"
.AddItem "Vieux-Québec/Vieux-Port"
.AddItem "Couronne Centre-Ville"
.AddItem "St-Roch"
.AddItem "Autres"

.ListIndex = 0
End With
End Sub


-------------------

--
Werne
-----------------------------------------------------------------------
Werner's Profile: http://www.excelforum.com/member.php...fo&userid=2430
View this thread: http://www.excelforum.com/showthread.php?threadid=39141


Werner[_34_]

ComboBox populating problem
 

A friend gave me the answer :


Code:
--------------------



Public Sub Worksheet_Activate()
With ComboBox1
.Clear

.AddItem "Nord"
.AddItem "Lebourgneuf"
.AddItem "Henri IV/Blvd Hamel"
.AddItem "Ste-Foy Périphérie"
.AddItem "Blvd Laurier"
.AddItem "Haute-Ville/Colline Parlementaire"
.AddItem "Vieux-Québec/Vieux-Port"
.AddItem "Couronne Centre-Ville"
.AddItem "St-Roch"
.AddItem "Autres"

.ListIndex = 0
End With

End Sub


--------------------


--
Werner
------------------------------------------------------------------------
Werner's Profile: http://www.excelforum.com/member.php...o&userid=24304
View this thread: http://www.excelforum.com/showthread...hreadid=391410



All times are GMT +1. The time now is 05:04 PM.

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