Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default automatically hiding a cell when value changes

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default automatically hiding a cell when value changes

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default automatically hiding a cell when value changes

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default automatically hiding a cell when value changes

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default automatically hiding a cell when value changes

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
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
Automatically Hiding Rows when certain cell value has been selecte Jason Excel Discussion (Misc queries) 4 November 18th 09 04:51 PM
AUtomatically hiding a row when a certain cell is blank kirbster1973 Excel Discussion (Misc queries) 6 January 21st 08 04:47 PM
hiding columns automatically dave glynn Excel Discussion (Misc queries) 2 February 1st 05 06:36 PM
hiding columns automatically dave glynn Excel Discussion (Misc queries) 0 February 1st 05 06:15 PM
Hiding Cells Automatically Hartsell Excel Programming 5 March 4th 04 02:38 PM


All times are GMT +1. The time now is 01:13 PM.

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

About Us

"It's about Microsoft Excel"