![]() |
Hide Rows Using Checkbox
I'd like to hide rows in tab 'Output' based on a checkbox in tab 'Input' ...
I've tried the code below but am getting the Run-time erro 1004 - Select Method of Range class failed. So obviously I'm not calling this correctly. Any help? Thanks. Private Sub checkbox3_Click() If CheckBox3 = True Then Sheets("Output").Select Rows("14:14").Select Selection.EntireRow.Hidden = False End If If CheckBox3 = False Then Sheets("Output").Select Rows("14:14").Select Selection.EntireRow.Hidden = True End If End Sub |
Hide Rows Using Checkbox
hi
i think it has to do with a sheet thing. the comboboxes are assigned to a sheet and you are wanting to move to another sheet so try it without all the selecting. Private Sub checkbox3_Click() If CheckBox3 = True Then Sheets("Output").Rows("14:14").EntireRow.Hidden = False End If If CheckBox3 = False Then Sheets("Output").Rows("14:14").EntireRow.Hidden = True End If End Sub tested. works in 03 Regards FSt1 "BJ" wrote: I'd like to hide rows in tab 'Output' based on a checkbox in tab 'Input' ... I've tried the code below but am getting the Run-time erro 1004 - Select Method of Range class failed. So obviously I'm not calling this correctly. Any help? Thanks. Private Sub checkbox3_Click() If CheckBox3 = True Then Sheets("Output").Select Rows("14:14").Select Selection.EntireRow.Hidden = False End If If CheckBox3 = False Then Sheets("Output").Select Rows("14:14").Select Selection.EntireRow.Hidden = True End If End Sub |
Hide Rows Using Checkbox
Private Sub checkbox3_Click()
If Sheets(Input).CheckBox3 = True Then Sheets("Output").Rows(14).Hidden = False End If If CheckBox3 = False Then Sheets("Output").Rows(14).Hidden = True End If End Sub Range("14:14") Rows(14) "BJ" wrote in message ... I'd like to hide rows in tab 'Output' based on a checkbox in tab 'Input' ... I've tried the code below but am getting the Run-time erro 1004 - Select Method of Range class failed. So obviously I'm not calling this correctly. Any help? Thanks. Private Sub checkbox3_Click() If CheckBox3 = True Then Sheets("Output").Select Rows("14:14").Select Selection.EntireRow.Hidden = False End If If CheckBox3 = False Then Sheets("Output").Select Rows("14:14").Select Selection.EntireRow.Hidden = True End If End Sub |
Hide Rows Using Checkbox
Just to add...
Since this code is behind a worksheet, the unqualified ranges (rows(14:14)) will belong to the sheet that owns the code. And since you can only select a range on the activesheet, your code fails. You could have used: If CheckBox3 = True Then with sheets("Output") .select .rows("14:14").select selection.entirerow.hidden = false end with else... But it's better not to select anything in your code. The resulting code will be much easier to read. I would have used something like: Private Sub checkbox3_Click() workSheets("Output").Rows(14).EntireRow.Hidden = Not (CheckBox3.Value) End Sub BJ wrote: I'd like to hide rows in tab 'Output' based on a checkbox in tab 'Input' ... I've tried the code below but am getting the Run-time erro 1004 - Select Method of Range class failed. So obviously I'm not calling this correctly. Any help? Thanks. Private Sub checkbox3_Click() If CheckBox3 = True Then Sheets("Output").Select Rows("14:14").Select Selection.EntireRow.Hidden = False End If If CheckBox3 = False Then Sheets("Output").Select Rows("14:14").Select Selection.EntireRow.Hidden = True End If End Sub -- Dave Peterson |
All times are GMT +1. The time now is 01:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com