Calling a macro from a conditional function

gessel

New Member
Joined
Apr 23, 2002
Messages
2
I'd like to hide rows based on data in the row as in

=IF(c5<>1,c12/2,HideRow)

Seems like it shouldn't be too tricky, but just creating a relative macro called "HideRow" doesn't work. Is it a declration thing? Redefining it as publicfunction seems to return "0".
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi
This seems like it will accomplish what you need.
I though I had seen syntax to call a procedure from a formula, but I cannot find any info that's even close...
Try this for now.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$5" Then _
If Range("C5") = 1 Then HideRow
End Sub

Tom
 
Upvote 0
Thank you fro your help, but I think I was a bit unclear. I want this to execute per row, so I'd drag-fill that command down the column
=IF(c5<>1,c12/2,HideRow)
=IF(c6<>1,c12/2,HideRow)
Each row being hidden on the c value.
...
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,181
Members
448,871
Latest member
hengshankouniuniu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top