Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
My excel macro recorder no longer shows up when recording macro | Excel Discussion (Misc queries) | |||
using a cell value to control a counter inside a macro and displaying macro value | Excel Worksheet Functions | |||
Macro needed to Paste Values and prevent Macro operation | Excel Discussion (Misc queries) | |||
Macro needed to Paste Values and prevent Macro operation | Excel Discussion (Misc queries) |