Hiding Checkbox Macro in accordance with the Combo Box

bignate1

New Member
Joined
Mar 14, 2016
Messages
4
So I am doing an excel project for my accounting class and I have a check box for my income statement that changes the currency of the values when clicked. There is also a combo box on this sheet that allows me to show nothing, the income statement I mentioned, a balance sheet, and a cash flow statement. The problem I need help with is I need to show the check box when Income Statement is selected in the combo box, but hide this macro when nothing, BS or CFS is selected? Is this possible? Thanks for any help.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi bignate1,

Think you'll be needing something along these lines...

Code:
Private Sub ComboBox1_Change()

If ComboBox1.Value = "Income Statement" Then
    CheckBox1.Visible = False
Else
    CheckBox1.Visible = True
End If

End Sub

Hope this helps,
Cheers,
Alan.
 
Upvote 0
So once you add the code how do you get the code to activate or get the macro to actually go away? Or should it do that automatically?? I went into the coding and followed these rules--
  1. Copy the sample code that you want to use
  2. Open the workbook in which you want to add the code
  3. Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
  4. Choose Insert | Module
  5. Where the cursor is flashing, choose Edit | Paste
but nothing happened? Is that even the right thing to do?
Thank you for your help, this is all really new to me and really confusing haha.
Hi bignate1,

Think you'll be needing something along these lines...

Code:
Private Sub ComboBox1_Change()

If ComboBox1.Value = "Income Statement" Then
    CheckBox1.Visible = False
Else
    CheckBox1.Visible = True
End If

End Sub

Hope this helps,
Cheers,
Alan.
 
Upvote 0
Hi bignate1,

If it is an ActiveX CheckBox and ComboBox, you'll have to go into the Developer tab and click on Design Mode, then right click on the your ComboBox and select View Code

Now you will need to modify the code to suit your needs, the code has the default name when you insert a ComboBox(ComboBox1) and Checkbox (CheckBox1)... when you right click and select view code, it will come up with something like this;

Code:
Private Sub [COLOR=#ff0000]CheckBox1[/COLOR]_Click()

End Sub

the bit before the underscore will be the name of it, you can do the same to find out the name of the checkbox

So you'll need to change this to match the names...

Code:
Private Sub [COLOR=#ff0000]ComboBox1[/COLOR]_Change()

If [COLOR=#ff0000]ComboBox1[/COLOR].Value = "Income Statement" Then
    [COLOR=#008000]CheckBox1[/COLOR].Visible = False
Else
    [COLOR=#008000]CheckBox1[/COLOR].Visible = True
End If

End Sub

Cheers,
Alan.
 
Upvote 0

Forum statistics

Threads
1,213,550
Messages
6,114,265
Members
448,558
Latest member
aivin

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