Looking to use a check box to hide/unhide cells on another worksheet excel 2016

Dowds

New Member
Joined
Feb 6, 2018
Messages
2
I am creating a quote form that has a check box for sales tax. On sheet1 the tax has a check box and sheet2 has a line for the sales tax included, which only shows if the check box is clicked. My code works when I test it (if I am on sheet2 viewing) UNTIL I enable the macro for the check box on sheet1. Then it throws a 400 error on the last line of either the unhide or hide code, depending on if box is checked or not. Any suggestions?

Sub CheckBox1_Click()

If Sheet1.Range("T17").Value = "True" Then
Call Unhide
ElseIf Sheet1.Range("T17").Value = "False" Then
Call Hide
Else
Return
End If
End Sub

Sub Unhide()
Sheet2.Range("A37:H37").Select
Selection.NumberFormat = "General"

End Sub

Sub Hide()
Sheet2.Range("A37:H37").Select
Selection.NumberFormat = ";;;"
End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi & welcome to MrExcel
You can only select cells on the active sheet, try this
Code:
Sub Unhide()
Sheet2.Range("A37:H37").NumberFormat = "General"

End Sub

Sub Hide()
Sheet2.Range("A37:H37").NumberFormat = ";;;"
End Sub
 
Last edited:
Upvote 0
Hi & welcome to MrExcel
You can only select cells on the active sheet, try this
Code:
Sub Unhide()
Sheet2.Range("A37:H37").NumberFormat = "General"

End Sub

Sub Hide()
Sheet2.Range("A37:H37").NumberFormat = ";;;"
End Sub

This worked! Thanks so much!
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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