![]() |
Populate Combobox
I have a combobox in a worksheet and on a userform, both containing the exact
same choices. As soon as a different choice is made in the combobox on my worksheet, my userform opens. I am struggling with getting the new item choice from my worksheet populated into the combobox on my userform. If Sheets("Sheet1").Range("F434").Value = 1 Then frmFields.txtActivityCmb.ListIndex = 0 End If I've tried adding the code to UserFrom_Activate, which doesn't work. It does work when added the code to a macro assigned to the combobox in the worksheet. But, it doesn't work until the the combobox selection is made a second time. I think that when the userform is opening, it's not catching the update in the worksheet yet. Any ideas how I can change the code to update the change in the worksheet before opening the userform. I don't want to save the worksheet though; I'd like the user to be able to decide if they want to save it. Thanks for your help. |
Populate Combobox
My apologies. My code works fine, I had it in the wrong place. Thank you.
"Alex" wrote: I have a combobox in a worksheet and on a userform, both containing the exact same choices. As soon as a different choice is made in the combobox on my worksheet, my userform opens. I am struggling with getting the new item choice from my worksheet populated into the combobox on my userform. If Sheets("Sheet1").Range("F434").Value = 1 Then frmFields.txtActivityCmb.ListIndex = 0 End If I've tried adding the code to UserFrom_Activate, which doesn't work. It does work when added the code to a macro assigned to the combobox in the worksheet. But, it doesn't work until the the combobox selection is made a second time. I think that when the userform is opening, it's not catching the update in the worksheet yet. Any ideas how I can change the code to update the change in the worksheet before opening the userform. I don't want to save the worksheet though; I'd like the user to be able to decide if they want to save it. Thanks for your help. |
Populate Combobox
Not sure what you are trying to do, but maybe this will help you get there.
Combo boxes do not exist until they are loaded and when they are unloaded they no longer exist. You cannot assign a value to a combo box that does not exist. So to do what it looks like you are trying to do, both combo boxes must be loaded at the time you try to assign the value of one to the other. HTH "Alex" wrote: I have a combobox in a worksheet and on a userform, both containing the exact same choices. As soon as a different choice is made in the combobox on my worksheet, my userform opens. I am struggling with getting the new item choice from my worksheet populated into the combobox on my userform. If Sheets("Sheet1").Range("F434").Value = 1 Then frmFields.txtActivityCmb.ListIndex = 0 End If I've tried adding the code to UserFrom_Activate, which doesn't work. It does work when added the code to a macro assigned to the combobox in the worksheet. But, it doesn't work until the the combobox selection is made a second time. I think that when the userform is opening, it's not catching the update in the worksheet yet. Any ideas how I can change the code to update the change in the worksheet before opening the userform. I don't want to save the worksheet though; I'd like the user to be able to decide if they want to save it. Thanks for your help. |
All times are GMT +1. The time now is 10:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com