View Full Version : Solved: Hidding a row from a function

called: "=FunctionHide(row(); if...true,false...)

Function FunctionHide(lvRow As Double, lvTrue As Boolean)

Dim lvRange As Range

If lvTrue = True Then

Set lvRange = Range("A1").Offset(lvRow - 1)

lvRange.EntireRow.Hidden = True

End If

McHide = lvTrue

End Function

can't I hide a range form a function?

trying it like a conditional format

You can't change attributes from within a worksheet function. Just no can do.

.

called: "=FunctionHide(row(); if...true,false...)

Function FunctionHide(lvRow As Double, lvTrue As Boolean)

Dim lvRange As Range

If lvTrue = True Then

Set lvRange = Range("A1").Offset(lvRow - 1)

lvRange.EntireRow.Hidden = True

End If

McHide = lvTrue

End Function

can't I hide a range form a function?

trying it like a conditional format

as xld said, changing an attribute from a worksheet function will not work, but you could get around that with a different approach:

whatever logic you would use to determine lvRow and lvTrue posts a value to a special location on the active sheet; the value should be lvRow

you use one of the sheet change procedures to test the value of the special location and if something is found there, the appropriate row is hidden.

this approach will not work in the general case, because you probably have more than one row that you might want to hide.

but it could work if we consider a special column instead of a special cell. Then you need only post T/F or 1/0 or Y/N or something like that for each row to the special column (which could be hidden)

the sheet change procedure then sequences down the special column to see what rows should be hidden. If "T" or "1" or "Y" or whatever you choose to use is found, that row is hidden.

You might extend the logic to if "F" or "0" or "N" or whatever is found, you unhide the row

thanks. i'll try that.

glad to help. Please let us know if this does what you want.

Powered by vBulletin® Version 4.2.5 Copyright © 2020 vBulletin Solutions Inc. All rights reserved.