Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Macro that will unhide then hide rows

Hi,

Would someone be so kind as to assist..please

I am trying to create a macro that will unhide and hid rows dependant on the
content of column A.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Macro that will unhide then hide rows

Rows("5:6").Hidden = Range("A1").Value = "value"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"minka" wrote in message
...
Hi,

Would someone be so kind as to assist..please

I am trying to create a macro that will unhide and hid rows dependant on

the
content of column A.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Macro that will unhide then hide rows

This goes in worksheet code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = 99 Then
Rows(10).EntireRow.Hidden = True
Else
Rows(10).EntireRow.Hidden = False
End If
End Sub


If cell A5 becomes 99 then row 10 is hidden, otherwise it is un-hidden.
--
Gary's Student


"Bob Phillips" wrote:

Rows("5:6").Hidden = Range("A1").Value = "value"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"minka" wrote in message
...
Hi,

Would someone be so kind as to assist..please

I am trying to create a macro that will unhide and hid rows dependant on

the
content of column A.




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Macro that will unhide then hide rows

Yes, this is good, but if you have 50 rows, you need to repeat the process 50
times! There must be a more efficient way of doing this with a large number
of rows?

"Gary''s Student" wrote:

This goes in worksheet code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = 99 Then
Rows(10).EntireRow.Hidden = True
Else
Rows(10).EntireRow.Hidden = False
End If
End Sub


If cell A5 becomes 99 then row 10 is hidden, otherwise it is un-hidden.
--
Gary's Student


"Bob Phillips" wrote:

Rows("5:6").Hidden = Range("A1").Value = "value"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"minka" wrote in message
...
Hi,

Would someone be so kind as to assist..please

I am trying to create a macro that will unhide and hid rows dependant on

the
content of column A.




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Macro that will unhide then hide rows

Hi Plum:

We can always hide a bunch of rows in one swell foop:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = 99 Then
Rows("10:60").EntireRow.Hidden = True
Else
Rows("10:60").EntireRow.Hidden = False
End If
End Sub

So fifty rows can be hidden with no more code than one row.
--
Gary's Student


"Plum" wrote:

Yes, this is good, but if you have 50 rows, you need to repeat the process 50
times! There must be a more efficient way of doing this with a large number
of rows?

"Gary''s Student" wrote:

This goes in worksheet code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = 99 Then
Rows(10).EntireRow.Hidden = True
Else
Rows(10).EntireRow.Hidden = False
End If
End Sub


If cell A5 becomes 99 then row 10 is hidden, otherwise it is un-hidden.
--
Gary's Student


"Bob Phillips" wrote:

Rows("5:6").Hidden = Range("A1").Value = "value"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"minka" wrote in message
...
Hi,

Would someone be so kind as to assist..please

I am trying to create a macro that will unhide and hid rows dependant on
the
content of column A.





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Macro that will unhide then hide rows

Yes, but what if you need the hiding of each row to be dependent on the cell
in column A? For example; A1 = 99 and therefore should be hidden, but A2 =
80, and should be shown, etc. etc... You would have to repeat the lines of
code 50 times in that case? (I know I'm going off on a tangent a bit but
it's something I"ve been trying to work out for ages!)
Regards.

"Gary''s Student" wrote:

Hi Plum:

We can always hide a bunch of rows in one swell foop:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = 99 Then
Rows("10:60").EntireRow.Hidden = True
Else
Rows("10:60").EntireRow.Hidden = False
End If
End Sub

So fifty rows can be hidden with no more code than one row.
--
Gary's Student


"Plum" wrote:

Yes, this is good, but if you have 50 rows, you need to repeat the process 50
times! There must be a more efficient way of doing this with a large number
of rows?

"Gary''s Student" wrote:

This goes in worksheet code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = 99 Then
Rows(10).EntireRow.Hidden = True
Else
Rows(10).EntireRow.Hidden = False
End If
End Sub


If cell A5 becomes 99 then row 10 is hidden, otherwise it is un-hidden.
--
Gary's Student


"Bob Phillips" wrote:

Rows("5:6").Hidden = Range("A1").Value = "value"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"minka" wrote in message
...
Hi,

Would someone be so kind as to assist..please

I am trying to create a macro that will unhide and hid rows dependant on
the
content of column A.



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Macro that will unhide then hide rows

Using my style of code

Private Sub Worksheet_Change(ByVal Target As Range)
Rows(10).EntireRow.Hidden = Range("A1").Value = 99
End Sub

but you should also be using Target somewhere as you are monitoring the
change event.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Gary''s Student" wrote in message
...
This goes in worksheet code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = 99 Then
Rows(10).EntireRow.Hidden = True
Else
Rows(10).EntireRow.Hidden = False
End If
End Sub


If cell A5 becomes 99 then row 10 is hidden, otherwise it is un-hidden.
--
Gary's Student


"Bob Phillips" wrote:

Rows("5:6").Hidden = Range("A1").Value = "value"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"minka" wrote in message
...
Hi,

Would someone be so kind as to assist..please

I am trying to create a macro that will unhide and hid rows dependant

on
the
content of column A.






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
Check Box Macro to hide and unhide a column Daphne Excel Worksheet Functions 9 June 26th 06 01:50 PM
How to program a macro to hide rows with conditionnal formating Turquoise_dax Excel Discussion (Misc queries) 5 June 20th 06 04:33 PM
Macro to hide blank cells in a range Dave Excel Discussion (Misc queries) 1 February 1st 06 11:55 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Insert rows Mr. G. Excel Worksheet Functions 3 March 31st 05 03:49 AM


All times are GMT +1. The time now is 05:57 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"