PDA

View Full Version : [SOLVED] Hidding a row from a function



Maka
09-22-2005, 06:58 AM
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 from a function?
trying it like a conditional format

Bob Phillips
09-22-2005, 09:49 AM
You can't change attributes from within a worksheet function. Just no can do.

.

MWE
09-22-2005, 10:50 AM
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

Maka
09-22-2005, 12:26 PM
thanks. i'll try that.

MWE
09-22-2005, 01:40 PM
thanks. i'll try that.
glad to help. Please let us know if this does what you want.