PC Review


Reply
Thread Tools Rate Thread

automatically hiding a cell when value changes

 
 
swiftcode
Guest
Posts: n/a
 
      6th Dec 2007
Hi all,

I have a problem on hiding a row when the value of a cell changes.

The following macro which works if i manualy input a zero value into the
cell, but when the cell is a formula and the result is zero, it doesent work
anymore.

Can anybody please help.

Thanks in advance.

the code is as follows:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$7" Then
If Target <= 0 Then
Cells(7, 3).EntireRow.Hidden = True
Else
Cells(7, 3).EntireRow.Hidden = False
End If
End If
End Sub
 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      6th Dec 2007
You need the Calculate Event, not the Change Event.
--
Gary''s Student - gsnu200760


"swiftcode" wrote:

> Hi all,
>
> I have a problem on hiding a row when the value of a cell changes.
>
> The following macro which works if i manualy input a zero value into the
> cell, but when the cell is a formula and the result is zero, it doesent work
> anymore.
>
> Can anybody please help.
>
> Thanks in advance.
>
> the code is as follows:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Address = "$C$7" Then
> If Target <= 0 Then
> Cells(7, 3).EntireRow.Hidden = True
> Else
> Cells(7, 3).EntireRow.Hidden = False
> End If
> End If
> End Sub

 
Reply With Quote
 
swiftcode
Guest
Posts: n/a
 
      7th Dec 2007
Hi Gary,

Thanks for your help. COuld you show me where to change this event?

"Gary''s Student" wrote:

> You need the Calculate Event, not the Change Event.
> --
> Gary''s Student - gsnu200760
>
>
> "swiftcode" wrote:
>
> > Hi all,
> >
> > I have a problem on hiding a row when the value of a cell changes.
> >
> > The following macro which works if i manualy input a zero value into the
> > cell, but when the cell is a formula and the result is zero, it doesent work
> > anymore.
> >
> > Can anybody please help.
> >
> > Thanks in advance.
> >
> > the code is as follows:
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Target.Address = "$C$7" Then
> > If Target <= 0 Then
> > Cells(7, 3).EntireRow.Hidden = True
> > Else
> > Cells(7, 3).EntireRow.Hidden = False
> > End If
> > End If
> > End Sub

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      7th Dec 2007
Private Sub Worksheet_Calculate()
If Range("C7").Value <= 0 Then
Cells(7, 3).EntireRow.Hidden = True
Else
Cells(7, 3).EntireRow.Hidden = False
End If
End Sub

This replaces your other macro
--
Gary''s Student - gsnu200760


"swiftcode" wrote:

> Hi Gary,
>
> Thanks for your help. COuld you show me where to change this event?
>
> "Gary''s Student" wrote:
>
> > You need the Calculate Event, not the Change Event.
> > --
> > Gary''s Student - gsnu200760
> >
> >
> > "swiftcode" wrote:
> >
> > > Hi all,
> > >
> > > I have a problem on hiding a row when the value of a cell changes.
> > >
> > > The following macro which works if i manualy input a zero value into the
> > > cell, but when the cell is a formula and the result is zero, it doesent work
> > > anymore.
> > >
> > > Can anybody please help.
> > >
> > > Thanks in advance.
> > >
> > > the code is as follows:
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > If Target.Address = "$C$7" Then
> > > If Target <= 0 Then
> > > Cells(7, 3).EntireRow.Hidden = True
> > > Else
> > > Cells(7, 3).EntireRow.Hidden = False
> > > End If
> > > End If
> > > End Sub

 
Reply With Quote
 
swiftcode
Guest
Posts: n/a
 
      9th Dec 2007
Hi Gary,

It works great. Thank you very much for your help.

Rgds
SC

"Gary''s Student" wrote:

> Private Sub Worksheet_Calculate()
> If Range("C7").Value <= 0 Then
> Cells(7, 3).EntireRow.Hidden = True
> Else
> Cells(7, 3).EntireRow.Hidden = False
> End If
> End Sub
>
> This replaces your other macro
> --
> Gary''s Student - gsnu200760
>
>
> "swiftcode" wrote:
>
> > Hi Gary,
> >
> > Thanks for your help. COuld you show me where to change this event?
> >
> > "Gary''s Student" wrote:
> >
> > > You need the Calculate Event, not the Change Event.
> > > --
> > > Gary''s Student - gsnu200760
> > >
> > >
> > > "swiftcode" wrote:
> > >
> > > > Hi all,
> > > >
> > > > I have a problem on hiding a row when the value of a cell changes.
> > > >
> > > > The following macro which works if i manualy input a zero value into the
> > > > cell, but when the cell is a formula and the result is zero, it doesent work
> > > > anymore.
> > > >
> > > > Can anybody please help.
> > > >
> > > > Thanks in advance.
> > > >
> > > > the code is as follows:
> > > >
> > > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > > If Target.Address = "$C$7" Then
> > > > If Target <= 0 Then
> > > > Cells(7, 3).EntireRow.Hidden = True
> > > > Else
> > > > Cells(7, 3).EntireRow.Hidden = False
> > > > End If
> > > > End If
> > > > 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
Automatically Hiding Rows when certain cell value has been selecte Jason Microsoft Excel Misc 4 18th Nov 2009 04:51 PM
AUtomatically hiding a row when a certain cell is blank =?Utf-8?B?a2lyYnN0ZXIxOTcz?= Microsoft Excel Misc 6 21st Jan 2008 04:47 PM
hiding columns automatically =?Utf-8?B?ZGF2ZSBnbHlubg==?= Microsoft Excel Misc 0 1st Feb 2005 06:15 PM
Hiding Cells Automatically =?Utf-8?B?SGFydHNlbGw=?= Microsoft Excel Programming 2 4th Mar 2004 12:31 PM
Hiding rows automatically based on the value in a cell Cathy Microsoft Excel Misc 2 6th Jan 2004 03:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:16 PM.