#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default macro help

I know that I can create a macro that will monitor a specific cell, and once
that cell equals the contents of another cell, an event will occur. The event
that I would like to occur would be for the row to be hidden. I've worked
just a very little bit with macros, so I'm looking for help in creating this
macro.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default macro help

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Columns("C:C").EntireColumn.Hidden = True Then
Exit Sub
Else
If Range("C1").Value = "hide" Then
Columns("C:C").Select
Selection.EntireColumn.Hidden = True
End If
End If
End Sub

"thaerr" wrote:

I know that I can create a macro that will monitor a specific cell, and once
that cell equals the contents of another cell, an event will occur. The event
that I would like to occur would be for the row to be hidden. I've worked
just a very little bit with macros, so I'm looking for help in creating this
macro.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default macro help

I'm afraid that I am in a little over my head here. I appreciate the help. If
I copy and paste this macro as is into a macro that I create, it doesn't
work. Do I need to replace (ByVal Target As Range) with data?

Please be patient with me. I'm taking baby steps here, lol.

"Mike" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Columns("C:C").EntireColumn.Hidden = True Then
Exit Sub
Else
If Range("C1").Value = "hide" Then
Columns("C:C").Select
Selection.EntireColumn.Hidden = True
End If
End If
End Sub

"thaerr" wrote:

I know that I can create a macro that will monitor a specific cell, and once
that cell equals the contents of another cell, an event will occur. The event
that I would like to occur would be for the row to be hidden. I've worked
just a very little bit with macros, so I'm looking for help in creating this
macro.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,090
Default macro help

The type of macro that you need is referred to as an "Event" macro. This
type of macro is triggered to fire (execute) upon the occurrence of some
event. Excel recognizes many events. In your case you would use a
Worksheet_Change event macro. Such a macro MUST be placed in the sheet
module of the sheet you want to work on. You would not place this type of
code in the middle of any other macro that you have in a regular module.
This type of macro is a stand-alone macro and it will fire if any change is
made to the contents of any cell in the entire sheet. The "Target" that you
see in the first row of the macro is the cell that changed.
Because this macro fires with any change to any cell in the sheet, it stands
to reason that you will want to limit the macro action to a change in any of
just a few cells, maybe just one cell. You do that with lines like:
If IsEmpty(Target.Value) Then Exit Sub
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
The first will stop all action by the macro if the change in the contents of
the cell was to make it blank.
The second line stops all action by the macro if the Target cell is not A1.
For your purposes, you would then have something that looks like:
If Target.Value = Range("C5").Value Then
Target.EntireRow.Hidden = True
End If
I hope this is of some help to you. HTH Otto
"thaerr" wrote in message
...
I'm afraid that I am in a little over my head here. I appreciate the help.
If
I copy and paste this macro as is into a macro that I create, it doesn't
work. Do I need to replace (ByVal Target As Range) with data?

Please be patient with me. I'm taking baby steps here, lol.

"Mike" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Columns("C:C").EntireColumn.Hidden = True Then
Exit Sub
Else
If Range("C1").Value = "hide" Then
Columns("C:C").Select
Selection.EntireColumn.Hidden = True
End If
End If
End Sub

"thaerr" wrote:

I know that I can create a macro that will monitor a specific cell, and
once
that cell equals the contents of another cell, an event will occur. The
event
that I would like to occur would be for the row to be hidden. I've
worked
just a very little bit with macros, so I'm looking for help in creating
this
macro.



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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


All times are GMT +1. The time now is 05:44 AM.

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"