PC Review


Reply
Thread Tools Rate Thread

Automatically Show/Hide Row based on cell value

 
 
plantechbl@earthlink.net
Guest
Posts: n/a
 
      14th Dec 2006
I need to have a row hidden or revealed based on a value in cell A16.

I have this code in the worksheet which works fine EXCEPT it apparently
resets the Undo stack and I don't have any undo capabilities in any
workbook that is open at the time.

I simply need to hide or reveal a row based on the cell value in A16
being "None". Any help either with this code or a totally different
approach will be greatly appreciated.

Private Sub Worksheet_Calculate()
Dim rCell As Range
For Each rCell In Range("a16")
rCell.EntireRow.Hidden = (rCell.Value = "None")
Next rCell
End Sub

 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      14th Dec 2006
Some clarification is needed. Perhaps you want to hide all cells in a larger
range if they have the same text as cell a16?
or
do you want to hide a16:a222 if they have none?
See, if you hide a16 only if it has none then how do you unhide it?

--
Don Guillett
SalesAid Software
(E-Mail Removed)
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I need to have a row hidden or revealed based on a value in cell A16.
>
> I have this code in the worksheet which works fine EXCEPT it apparently
> resets the Undo stack and I don't have any undo capabilities in any
> workbook that is open at the time.
>
> I simply need to hide or reveal a row based on the cell value in A16
> being "None". Any help either with this code or a totally different
> approach will be greatly appreciated.
>
> Private Sub Worksheet_Calculate()
> Dim rCell As Range
> For Each rCell In Range("a16")
> rCell.EntireRow.Hidden = (rCell.Value = "None")
> Next rCell
> End Sub
>



 
Reply With Quote
 
plantechbl@earthlink.net
Guest
Posts: n/a
 
      14th Dec 2006
Don,
Cell A16 is linked to another cell which is always visible, so when the
data entry cell C15="None" A16 will="None". As C15 value changes A16
will change and reveal the row. In this manner I can control the
visibility of many rows based on the value of a single always visible
value.

Thanks for such a prompt reply!
Bill

Don Guillett wrote:
> Some clarification is needed. Perhaps you want to hide all cells in a larger
> range if they have the same text as cell a16?
> or
> do you want to hide a16:a222 if they have none?
> See, if you hide a16 only if it has none then how do you unhide it?
>
> --
> Don Guillett
> SalesAid Software
> (E-Mail Removed)
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I need to have a row hidden or revealed based on a value in cell A16.
> >
> > I have this code in the worksheet which works fine EXCEPT it apparently
> > resets the Undo stack and I don't have any undo capabilities in any
> > workbook that is open at the time.
> >
> > I simply need to hide or reveal a row based on the cell value in A16
> > being "None". Any help either with this code or a totally different
> > approach will be greatly appreciated.
> >
> > Private Sub Worksheet_Calculate()
> > Dim rCell As Range
> > For Each rCell In Range("a16")
> > rCell.EntireRow.Hidden = (rCell.Value = "None")
> > Next rCell
> > End Sub
> >


 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      15th Dec 2006
then try this to hide row 16 when cell a15 changes

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$15" Then Exit Sub
If UCase(Target) = "NONE" Then
Rows(16).Hidden = True
Else
Rows(16).Hidden = False
End If
End Sub


--
Don Guillett
SalesAid Software
(E-Mail Removed)
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Don,
> Cell A16 is linked to another cell which is always visible, so when the
> data entry cell C15="None" A16 will="None". As C15 value changes A16
> will change and reveal the row. In this manner I can control the
> visibility of many rows based on the value of a single always visible
> value.
>
> Thanks for such a prompt reply!
> Bill
>
> Don Guillett wrote:
>> Some clarification is needed. Perhaps you want to hide all cells in a
>> larger
>> range if they have the same text as cell a16?
>> or
>> do you want to hide a16:a222 if they have none?
>> See, if you hide a16 only if it has none then how do you unhide it?
>>
>> --
>> Don Guillett
>> SalesAid Software
>> (E-Mail Removed)
>> <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >I need to have a row hidden or revealed based on a value in cell A16.
>> >
>> > I have this code in the worksheet which works fine EXCEPT it apparently
>> > resets the Undo stack and I don't have any undo capabilities in any
>> > workbook that is open at the time.
>> >
>> > I simply need to hide or reveal a row based on the cell value in A16
>> > being "None". Any help either with this code or a totally different
>> > approach will be greatly appreciated.
>> >
>> > Private Sub Worksheet_Calculate()
>> > Dim rCell As Range
>> > For Each rCell In Range("a16")
>> > rCell.EntireRow.Hidden = (rCell.Value = "None")
>> > Next rCell
>> > End Sub
>> >

>



 
Reply With Quote
 
plantechbl@earthlink.net
Guest
Posts: n/a
 
      15th Dec 2006
Don,
I got it to work fine if I use the value in the data entry cell C15
(and I have Undo back again).
My final code looks like this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$C$15" Then Exit Sub
If UCase(Target) = "NONE" Then
Rows(16).Hidden = True
'Rows(18).Hidden = True
Else
Rows(16).Hidden = False
'Rows(18).Hidden = False
End If
End Sub

Thank you very much for your help,
Bill

Don Guillett wrote:
> then try this to hide row 16 when cell a15 changes
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Address <> "$A$15" Then Exit Sub
> If UCase(Target) = "NONE" Then
> Rows(16).Hidden = True
> Else
> Rows(16).Hidden = False
> End If
> End Sub
>
>
> --
> Don Guillett
> SalesAid Software
> (E-Mail Removed)
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Don,
> > Cell A16 is linked to another cell which is always visible, so when the
> > data entry cell C15="None" A16 will="None". As C15 value changes A16
> > will change and reveal the row. In this manner I can control the
> > visibility of many rows based on the value of a single always visible
> > value.
> >
> > Thanks for such a prompt reply!
> > Bill
> >
> > Don Guillett wrote:
> >> Some clarification is needed. Perhaps you want to hide all cells in a
> >> larger
> >> range if they have the same text as cell a16?
> >> or
> >> do you want to hide a16:a222 if they have none?
> >> See, if you hide a16 only if it has none then how do you unhide it?
> >>
> >> --
> >> Don Guillett
> >> SalesAid Software
> >> (E-Mail Removed)
> >> <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> >I need to have a row hidden or revealed based on a value in cell A16.
> >> >
> >> > I have this code in the worksheet which works fine EXCEPT it apparently
> >> > resets the Undo stack and I don't have any undo capabilities in any
> >> > workbook that is open at the time.
> >> >
> >> > I simply need to hide or reveal a row based on the cell value in A16
> >> > being "None". Any help either with this code or a totally different
> >> > approach will be greatly appreciated.
> >> >
> >> > Private Sub Worksheet_Calculate()
> >> > Dim rCell As Range
> >> > For Each rCell In Range("a16")
> >> > rCell.EntireRow.Hidden = (rCell.Value = "None")
> >> > Next rCell
> >> > End Sub
> >> >

> >


 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      15th Dec 2006
Glad to help

--
Don Guillett
SalesAid Software
(E-Mail Removed)
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Don,
> I got it to work fine if I use the value in the data entry cell C15
> (and I have Undo back again).
> My final code looks like this:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Address <> "$C$15" Then Exit Sub
> If UCase(Target) = "NONE" Then
> Rows(16).Hidden = True
> 'Rows(18).Hidden = True
> Else
> Rows(16).Hidden = False
> 'Rows(18).Hidden = False
> End If
> End Sub
>
> Thank you very much for your help,
> Bill
>
> Don Guillett wrote:
>> then try this to hide row 16 when cell a15 changes
>>
>> Private Sub Worksheet_Change(ByVal Target As Range)
>> If Target.Address <> "$A$15" Then Exit Sub
>> If UCase(Target) = "NONE" Then
>> Rows(16).Hidden = True
>> Else
>> Rows(16).Hidden = False
>> End If
>> End Sub
>>
>>
>> --
>> Don Guillett
>> SalesAid Software
>> (E-Mail Removed)
>> <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Don,
>> > Cell A16 is linked to another cell which is always visible, so when the
>> > data entry cell C15="None" A16 will="None". As C15 value changes A16
>> > will change and reveal the row. In this manner I can control the
>> > visibility of many rows based on the value of a single always visible
>> > value.
>> >
>> > Thanks for such a prompt reply!
>> > Bill
>> >
>> > Don Guillett wrote:
>> >> Some clarification is needed. Perhaps you want to hide all cells in a
>> >> larger
>> >> range if they have the same text as cell a16?
>> >> or
>> >> do you want to hide a16:a222 if they have none?
>> >> See, if you hide a16 only if it has none then how do you unhide it?
>> >>
>> >> --
>> >> Don Guillett
>> >> SalesAid Software
>> >> (E-Mail Removed)
>> >> <(E-Mail Removed)> wrote in message
>> >> news:(E-Mail Removed)...
>> >> >I need to have a row hidden or revealed based on a value in cell A16.
>> >> >
>> >> > I have this code in the worksheet which works fine EXCEPT it
>> >> > apparently
>> >> > resets the Undo stack and I don't have any undo capabilities in any
>> >> > workbook that is open at the time.
>> >> >
>> >> > I simply need to hide or reveal a row based on the cell value in A16
>> >> > being "None". Any help either with this code or a totally different
>> >> > approach will be greatly appreciated.
>> >> >
>> >> > Private Sub Worksheet_Calculate()
>> >> > Dim rCell As Range
>> >> > For Each rCell In Range("a16")
>> >> > rCell.EntireRow.Hidden = (rCell.Value = "None")
>> >> > Next rCell
>> >> > End Sub
>> >> >
>> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide and Show Rows based on Cell Value echamp525 Microsoft Excel Misc 2 16th Sep 2010 01:07 AM
SHow Hide COlumns based on cell value Walt H Microsoft Excel Programming 4 13th Jun 2008 04:43 PM
GridView: how to hide/show controls based on a value in another cell? dan Microsoft ASP .NET 0 18th Apr 2008 07:43 PM
Can Excel hide a row automatically based on value in a cell? =?Utf-8?B?UkpRTUFO?= Microsoft Excel Programming 2 7th Jul 2005 08:56 AM
How do I automatically hide columns in a worksheet based on a cell value? dkhedkar Microsoft Excel Worksheet Functions 1 5th Mar 2005 12:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:28 PM.