ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Add items to a combo box and make them available after closing the sheet (https://www.excelbanter.com/excel-discussion-misc-queries/147893-add-items-combo-box-make-them-available-after-closing-sheet.html)

[email protected]

Add items to a combo box and make them available after closing the sheet
 
Alright, I have a user form that I have been building and it has the
following code within..

Private Sub UserForm_Initialize()
cboName.Value = ""
cboTestNumber.Value = ""
txtScore.Value = ""

With cboTestNumber
.AddItem "Sec+"
.AddItem "270"
.AddItem "290"
.AddItem "291"
.AddItem "293"
.AddItem "294"
.AddItem "298"
.AddItem "299"
End With

cboName.SetFocus

End Sub




Works great.. At least as far as the cboTestNumber since they are
defined with .AddItem. In another sub I have the following lines
that obviously takes the value from the form and adds it to the combo
box.

With cboName
..AddItem cboName.Value
End With

This also works like a treat and dynamically adds values to the 'Name'
combo box as they are entered so they do not have to be re-typed
later.. BUT if I save the sheet, close out and open again (or reset
the Macro) obviously the value in cboName.Value goes away and my combo
box is once again empty...

What I would like to happen is once a name is entered in the first
time, that the name be added to the 'Name' combo box list and be
available when pulling up the sheet the next day.

Is this possible?

Thanks in advance...

David


Dave Peterson

Add items to a combo box and make them available after closing thesheet
 
Maybe you can store the values on a hidden worksheet and then populate from
there???

wrote:

Alright, I have a user form that I have been building and it has the
following code within..

Private Sub UserForm_Initialize()
cboName.Value = ""
cboTestNumber.Value = ""
txtScore.Value = ""

With cboTestNumber
.AddItem "Sec+"
.AddItem "270"
.AddItem "290"
.AddItem "291"
.AddItem "293"
.AddItem "294"
.AddItem "298"
.AddItem "299"
End With

cboName.SetFocus

End Sub

Works great.. At least as far as the cboTestNumber since they are
defined with .AddItem. In another sub I have the following lines
that obviously takes the value from the form and adds it to the combo
box.

With cboName
.AddItem cboName.Value
End With

This also works like a treat and dynamically adds values to the 'Name'
combo box as they are entered so they do not have to be re-typed
later.. BUT if I save the sheet, close out and open again (or reset
the Macro) obviously the value in cboName.Value goes away and my combo
box is once again empty...

What I would like to happen is once a name is entered in the first
time, that the name be added to the 'Name' combo box list and be
available when pulling up the sheet the next day.

Is this possible?

Thanks in advance...

David


--

Dave Peterson


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

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