Help on Checkbox Macro

kwroche

New Member
Joined
Jun 18, 2008
Messages
16
Hello,
I have a series of check box macros that are set to hide and unhide rows when checked and unchecked. Only problem is that whenever I insert a new line into the page, everything gets thrown off. Is there anyway to fix that?
The following is the code I use
Sub Oxygen()
'
' Oxygen Macro
' Macro recorded 5/16/2008 by Kyle Roche
'
Rows("32:32").EntireRow.Hidden = True
Rows("42:42").EntireRow.Hidden = True
Rows("50:51").EntireRow.Hidden = True
Rows("61:61").EntireRow.Hidden = True
Rows("69:69").EntireRow.Hidden = True
Rows("147:182").EntireRow.Hidden = True
Rows("295:295").EntireRow.Hidden = True
Rows("304:304").EntireRow.Hidden = True
Rows("314:314").EntireRow.Hidden = True
Rows("322:322").EntireRow.Hidden = True
Rows("332:332").EntireRow.Hidden = True
'
End Sub
Sub YesOxygen()
'
' YesOxygen Macro
' Macro recorded 5/16/2008 by Kyle Roche
'
Rows("32:32").EntireRow.Hidden = False
Rows("42:42").EntireRow.Hidden = False
Rows("50:51").EntireRow.Hidden = False
Rows("61:61").EntireRow.Hidden = False
Rows("69:69").EntireRow.Hidden = False
Rows("147:182").EntireRow.Hidden = False
Rows("295:295").EntireRow.Hidden = False
Rows("304:304").EntireRow.Hidden = False
Rows("314:314").EntireRow.Hidden = False
Rows("322:322").EntireRow.Hidden = False
Rows("332:332").EntireRow.Hidden = False
'
End Sub
Sub OxygenCheckBox()
Dim cb As Excel.CheckBox


Set cb = Excel.ActiveSheet.CheckBoxes(Application.Caller)
If cb.Value = xlOn Then
Call YesOxygen
Else
Call Oxygen
End If

End Sub
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

kwroche

New Member
Joined
Jun 18, 2008
Messages
16
so say if I have "oxygen" in the first cell of each column that needs to be hidden, how would i go about writing the code for that?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,521
Messages
5,596,651
Members
414,083
Latest member
Mrsash

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
Top