ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ComboBox Issue: Write to WorkSheet (https://www.excelbanter.com/excel-programming/329498-combobox-issue-write-worksheet.html)

Paul Martin

ComboBox Issue: Write to WorkSheet
 
Hi All

I have a ComboBox on a UserForm. The TextBoxes on the form are
populated according to the ComboBox selection, using the Change event
of the ComboBox.

The user can change the values in the ComboBox, and I want these
changes to be stored on a hidden worksheet so that these repopulate the
ComboBox when needed. I thought I'd change the ComboBox's
ControlSource on the AfterUpdate event, but by this stage ListIndex has
been lost (reverted to -1).

I've tried using other events, but am getting nowhere. Any
suggestions?

Thanks in advance

Paul Martin
Melbourne, Australia


Tom Ogilvy

ComboBox Issue: Write to WorkSheet
 
Private Sub Combobox1_Click()
Dim rng as Range, idex as Long
sStr = Combobox1.RowSource
set rng = Range(Combobox1.RowSource)
idex = Combobox1.ListIndex
Combobox1.RowSource = ""

' make your changes,
' then reset the rowsource. Determine new one or use sStr
Combobox1.RowSource = "something"

End Sub

--
Regards,
Tom Ogilvy


"Paul Martin" wrote in message
oups.com...
Hi All

I have a ComboBox on a UserForm. The TextBoxes on the form are
populated according to the ComboBox selection, using the Change event
of the ComboBox.

The user can change the values in the ComboBox, and I want these
changes to be stored on a hidden worksheet so that these repopulate the
ComboBox when needed. I thought I'd change the ComboBox's
ControlSource on the AfterUpdate event, but by this stage ListIndex has
been lost (reverted to -1).

I've tried using other events, but am getting nowhere. Any
suggestions?

Thanks in advance

Paul Martin
Melbourne, Australia




Paul Martin

ComboBox Issue: Write to WorkSheet
 
OK, I didn't think about clearing RowSource. Simple, but clever.

Thanks Tom

Paul Martin
Melbourne, Australia



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

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