Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 788
Default Code for button to hide/unhide rows

I'm having problems with this code. I've a worksheet for all levels of user.
Rows A1-G7 = header, Rows 8+ & Columns A-G = user data, Column G as trigger.
Would like to have Sub Button1_Click() to hide rows, if date or data in G;
and have a second button Sub Button2_Click() to unhide all. I'm close but no
cigar.
--
Regards
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Code for button to hide/unhide rows

Something like ....??

Sub HideG()
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
For i = 7 To lastrow
If Cells(i, "G") < "" Then Rows(i).Hidden = True
Next i
End Sub

Sub unhideG()
Rows.Hidden = False
End Sub

"Chris" wrote:

I'm having problems with this code. I've a worksheet for all levels of user.
Rows A1-G7 = header, Rows 8+ & Columns A-G = user data, Column G as trigger.
Would like to have Sub Button1_Click() to hide rows, if date or data in G;
and have a second button Sub Button2_Click() to unhide all. I'm close but no
cigar.
--
Regards

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Code for button to hide/unhide rows

Or one macro for both jobs

Sub HideG()
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
For i = 7 To lastrow
Rows(i).Hidden = Cells(i, "G").Value < ""
Next i
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Toppers" wrote in message
...
Something like ....??

Sub HideG()
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
For i = 7 To lastrow
If Cells(i, "G") < "" Then Rows(i).Hidden = True
Next i
End Sub

Sub unhideG()
Rows.Hidden = False
End Sub

"Chris" wrote:

I'm having problems with this code. I've a worksheet for all levels of
user.
Rows A1-G7 = header, Rows 8+ & Columns A-G = user data, Column G as
trigger.
Would like to have Sub Button1_Click() to hide rows, if date or data in
G;
and have a second button Sub Button2_Click() to unhide all. I'm close but
no
cigar.
--
Regards



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 788
Default Code for button to hide/unhide rows

Thanks both work. Just had to assign header as it wanted to hide as well.
--
Regards


"Bob Phillips" wrote:

Or one macro for both jobs

Sub HideG()
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
For i = 7 To lastrow
Rows(i).Hidden = Cells(i, "G").Value < ""
Next i
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Toppers" wrote in message
...
Something like ....??

Sub HideG()
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
For i = 7 To lastrow
If Cells(i, "G") < "" Then Rows(i).Hidden = True
Next i
End Sub

Sub unhideG()
Rows.Hidden = False
End Sub

"Chris" wrote:

I'm having problems with this code. I've a worksheet for all levels of
user.
Rows A1-G7 = header, Rows 8+ & Columns A-G = user data, Column G as
trigger.
Would like to have Sub Button1_Click() to hide rows, if date or data in
G;
and have a second button Sub Button2_Click() to unhide all. I'm close but
no
cigar.
--
Regards




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Code for button to hide/unhide rows

Bob,
When I run first time, rows 7 onwards are hidden as expected. when
I re-run they are not unhidden as LASTROW is <7.

Or I am misunderstanding something?

"Bob Phillips" wrote:

Or one macro for both jobs

Sub HideG()
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
For i = 7 To lastrow
Rows(i).Hidden = Cells(i, "G").Value < ""
Next i
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Toppers" wrote in message
...
Something like ....??

Sub HideG()
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
For i = 7 To lastrow
If Cells(i, "G") < "" Then Rows(i).Hidden = True
Next i
End Sub

Sub unhideG()
Rows.Hidden = False
End Sub

"Chris" wrote:

I'm having problems with this code. I've a worksheet for all levels of
user.
Rows A1-G7 = header, Rows 8+ & Columns A-G = user data, Column G as
trigger.
Would like to have Sub Button1_Click() to hide rows, if date or data in
G;
and have a second button Sub Button2_Click() to unhide all. I'm close but
no
cigar.
--
Regards






  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 788
Default Code for button to hide/unhide rows

Toppers
Code work flawlessly, after changing last header row, as it wanted to hide
as well. Thankyou for your help.
--
Regards
Chris

"Toppers" wrote:

Something like ....??

Sub HideG()
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
For i = 7 To lastrow
If Cells(i, "G") < "" Then Rows(i).Hidden = True
Next i
End Sub

Sub unhideG()
Rows.Hidden = False
End Sub

"Chris" wrote:

I'm having problems with this code. I've a worksheet for all levels of user.
Rows A1-G7 = header, Rows 8+ & Columns A-G = user data, Column G as trigger.
Would like to have Sub Button1_Click() to hide rows, if date or data in G;
and have a second button Sub Button2_Click() to unhide all. I'm close but no
cigar.
--
Regards

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
hide or unhide rows with button Bea Excel Discussion (Misc queries) 15 September 19th 07 07:03 PM
Hide / Unhide columns and rows PaulM Excel Discussion (Misc queries) 8 September 6th 07 12:14 AM
Command Button to Hide/Unhide Rows Bea Excel Discussion (Misc queries) 4 March 16th 06 03:21 PM
Hide Unhide Rows blackstar Excel Discussion (Misc queries) 2 February 6th 06 09:36 PM
Conditional Hide/Unhide Rows Gwen H Excel Discussion (Misc queries) 4 March 30th 05 06:52 AM


All times are GMT +1. The time now is 12:07 PM.

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"