Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
BJ BJ is offline
external usenet poster
 
Posts: 51
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
use checkbox to hide rows ScottB Excel Discussion (Misc queries) 2 August 20th 08 01:05 PM
Hide & Unhide with a Checkbox Jonathan Excel Programming 5 October 5th 05 12:16 PM
hide rows from checkbox Qaspec Excel Programming 1 May 25th 05 10:32 PM
Checkbox to hide and unhide rows Please. Steved Excel Worksheet Functions 2 December 6th 04 11:30 PM
Checkbox to hide or show rows Dave Peterson[_3_] Excel Programming 0 January 21st 04 03:23 AM


All times are GMT +1. The time now is 10:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"