View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
ron
 
Posts: n/a
Default How can I invoke running a macro from within an "IF" function.

I want to Hide a range of rows (16:18 in this example) if "no" is in a range
of cells and Unhide the same range of rows if "yes" is in the same range of
cells. The "Hide", "Unhide" macros (below) work if I select one from the Run
Macro list, of course. But, how can I call for it to run from an "IF"
function. I know this statement is wrong, but it may help you know what I am
looking for: =IF (A1:A15="no",Run Hide,IF (A1:A15="yes",Run Unhide),"")

Sub Hide()
'
' Hide Macro
'
Rows("16:18").Select
Selection.EntireRow.Hidden = True
End Sub
___________________
Sub Unhide()
'
' Unhide Macro
'
Rows("16:18").Select
Selection.EntireRow.Hidden = False
End Sub