|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
VBA Code Needed that will Hide / Unhide a row when used with a "Check Box"
I need a VBA code that will, when used with a Form Control "Check Box", will unhide / hide a row. To be more exact, I'm needing the code to "Hide" row 34 when unchecked and "Unhide" the same row when checked. Can someone help me please. By the way, I'm using Excel 2010. Thank you!!!
|
#2
|
|||
|
|||
Bear,
check your post in MrExcel. Also I sent you a file. |
#3
|
||||
|
||||
Barry, I've never hidden a row but I think it's just a matter of setting the row's Height to 0 (and, of course, of restoring its height to something when the box is unchecked). You should be able to confirm this easily: Just record a macro and hide the row manually, then examine the macro that is created. If that doesn't work as expected, let me know what it did do and maybe I can help you figure it out. (Hint: Almost all novices say simply "that didn't work". That's why I specified "let me know what it did do" :-).) Also, let me know if you don't know how to record a macro, or examine it afterward, and I'll walk you through it.
|
#4
|
||||
|
||||
Barry,
Please don't post the same question in multiple locations on this board. I've merged the threads & deleted the duplicate post. Also cross-posted and solved (before there'd even been a reply here) at http://www.mrexcel.com/forum/excel-questions/786269-visual-basic-applications-code-needed-will-hide-unhide-row-when-used-check-box-2.html For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
This is the VBA code I used and it worked great! Of course I had to change a little of the wording to match my sheet.
Private Sub CheckBox1_Click() Dim check As OLEObject Set check = Sheets("FEBRUARY").OLEObjects("CheckBox1") If check.Object Then Rows("34:34").EntireRow.Hidden = False Else Rows("34:34").EntireRow.Hidden = True End If End Sub |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Possible to Protect / Hide VBA Macro Code When Transferred to a Different Computer? | Duvdev | Word VBA | 2 | 04-09-2014 10:56 PM |
I need help with macro...code needed for automatic sorting | chefmate | Excel Programming | 1 | 08-26-2012 01:04 AM |
Check box macro help needed | Aflac | Word | 4 | 03-24-2012 07:11 PM |
Hide/Unhide pictures | maloneb | PowerPoint | 1 | 01-18-2012 03:34 PM |
Unhide and Re-hide in Excel 2003 | thorgal67 | Excel | 1 | 07-16-2009 07:06 AM |