Userform "Change Event" won't happen multiple times

Chris Macro

Well-known Member
Joined
Nov 2, 2011
Messages
1,345
Office Version
  1. 365
Platform
  1. Windows
I have a userform created with two dropdown boxes. I want the contents in the 2nd box to change based on what the first box says. I created the below "Change Event" to code the possible outcomes. I find that if I change the 1st box initially the 2nd box will load the correct contents. However, if I go to change the 1st box a second time the 2nd box keeps the previously loaded information. Am I missing something?

<font face=Calibri><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> userform_Initialize()<br><br><SPAN style="color:#007F00">'Drop down box options for Statements</SPAN><br>    <SPAN style="color:#00007F">With</SPAN> Me.Statement<br>        .AddItem "Assets"<br>        .AddItem "Liabilities"<br>        .AddItem "Income Stmt"<br>        .AddItem "Income Stmt (QtoQ)"<br>        .AddItem "Income Stmt (MtoM)"<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><br><SPAN style="color:#007F00">'Default setting for the Year</SPAN><br>    Start_Year = Year(Date)<br>    End_Year = Year(Date)<br>   <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Statement_Change()<br><br><SPAN style="color:#00007F">If</SPAN> Statement = "Assets" <SPAN style="color:#00007F">Then</SPAN><br>    <SPAN style="color:#00007F">With</SPAN> Me.Account<br>        .AddItem "**    111000 CASH AND CASH EQUIVALENTS"<br>        .AddItem "***   114000 NET ACCOUNT RECEIVABLES"<br>        .AddItem "**    117000 TOTAL INVENTORIES"<br>        .AddItem "**    118000 TOTAL OTHER CURRENT ASSETS"<br>        .AddItem "****  119999 Total Current Assets"<br>        .AddItem "*     130011 INVESTMENT IN SUBSIDIARIES"<br>        .AddItem "**    120000 TOTAL PROPERTY, PLANT AND EQUIPME"<br>        .AddItem "**    133000 TOTAL INTANGIBLE AND OTHER ASSETS"<br>        .AddItem "***** 100000 TOTAL ASSETS"<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><br><SPAN style="color:#00007F">ElseIf</SPAN> Statement = "Liabilities" <SPAN style="color:#00007F">Then</SPAN><br>    <SPAN style="color:#00007F">With</SPAN> Me.Account<br>        .AddItem "**     211000 TOTAL ACCOUNTS PAYABLE"<br>        .AddItem "**     213000 TOTAL ACCRUED EXPENSES"<br>        .AddItem "*      215011 CURRENT PORTION OF LONG TERM DEBT"<br>        .AddItem "***    210000 TOTAL CURRENT LIABILITIES"<br>        .AddItem "*      221011 LONG TERM DEBT"<br>        .AddItem "**     223000 OTHER LONG TERM OBLIGATIONS"<br>        .AddItem "*      223500 LIABILITIES SUBJECT TO COMPROMISE"<br>        .AddItem "****   TOTAL LIABILITIES"<br>        .AddItem "*      231111 COMMON STOCK"<br>        .AddItem "*      235011 ADDITIONAL PAID IN CAPITAL"<br>        .AddItem "**     236000 TOTAL ACCUMULATED DEFICIT"<br>        .AddItem "*      234013 ACCUM.OTHER COMPREHENSIVE INCOME"<br>        .AddItem "***    230000 TOTAL STOCKHOLDER'S EQUITY"<br>        .AddItem "*****  200000 TOTAL LIABILITIES AND EQUITY"<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <br><SPAN style="color:#00007F">ElseIf</SPAN> Statement = "Income Stmt" <SPAN style="color:#00007F">Or</SPAN> Statement = "Income Stmt (QtoQ)" <SPAN style="color:#00007F">Or</SPAN> Statement = "Income Stmt (MtoM)" <SPAN style="color:#00007F">Then</SPAN><br>    <SPAN style="color:#00007F">With</SPAN> Me.Account<br>        .AddItem "COGS**     Net Sales"<br>        .AddItem "SG&A***    Total Cost of Goods Sold"<br>        .AddItem "SG&A**     Total SG&A"<br>        .AddItem "SG&A**     Interest Expense"<br>        .AddItem "SG&A**     Other (Income) Expense, net"<br>        .AddItem "SG&A****   (Income) Loss Before Reorg Items & Tax"<br>        .AddItem "SG&A*****  (Income) Loss Before Inc Taxes (Benefit)"<br>        .AddItem "SG&A**     Income Tax Expense"<br>        .AddItem "0****** Net Income"<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <br><SPAN style="color:#00007F">Else</SPAN><br>    MsgBox "Please select a Statement from the dropdown menu."<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><br>End <SPAN style="color:#00007F">Sub</SPAN></FONT>
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
You're just adding new data. You need:
Code:
Me.Account.Clear
to remove the existing data or use the .List property with an array instead of AddItem
 
Upvote 0
Thanks Rory! I knew it had to be something small like that!
 
Upvote 0

Forum statistics

Threads
1,215,048
Messages
6,122,862
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top