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

How do you know which rows to hide/unhide?

If you specify

A1="no" -- hide rows x:y
A2="no" -- hide rows z:w
....

You may find that you get an acceptable response.

ron wrote:

Thanks. However, the intent is this. The default values in A1:A15 will be
"no" If a person answers yes to one of those cells, I want specific other
rows to unfold (unhide) revealing some additional data to be inserted by the
person.

"Dave Peterson" wrote:

You can't run macros from formulas, but it might be easier than you think.

Select your range.
data|filter|autofilter

Then use the dropdown arrow in the first cell in column A and choose to show the
Yes's (or use custom, not equal to "no").

It's a very easy way to hide/show rows.

Data|filter|show all

will show all the data.

ron wrote:

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


--

Dave Peterson


--

Dave Peterson