Consulting

Results 1 to 5 of 5

Thread: Hidding a row from a function

  1. #1

    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 from a function?
    trying it like a conditional format

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You can't change attributes from within a worksheet function. Just no can do.

    .
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by Maka
    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:

    1. 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
    2. 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.
    3. this approach will not work in the general case, because you probably have more than one row that you might want to hide.
    4. 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)
    5. 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.
    6. You might extend the logic to if "F" or "0" or "N" or whatever is found, you unhide the row
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  4. #4
    thanks. i'll try that.

  5. #5
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by Maka
    thanks. i'll try that.
    glad to help. Please let us know if this does what you want.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •