[Solved] VBA : Hide

  • I have a sheet on which a group of cells expects an entry, either text or number. These can be 5 or 6 rows deep by 2 across.
    Sometimes, only 5 of the rows have to be used and I would, on such an occasion, like to be able to code it in such a way as to hide the sixth row.


    I have tried to use Entirerow.Hidden but no matter how I try I get an error.


    In this case, the code runs:-


    If cells(6,2)="" then
    Range("A14").Entirerow.Hidden = true
    else
    Range("A14").Entirerow.Hidden = false
    end if


    This results in the error "Unable to set the hidden property in the Range class"


    I'd be grateful if someone could point me in the right direction for clearly the Range part of the instruction is wrong.

    Les

  • Hi Les,


    I could use the SAME code to hide the range. It worked.


    Just make sure that your sheet is not protected.


    Also, as per your requirements, you do not want user to enter anywhere except where you want... why don't you try to unlock the entry fields and then protect?


    Hope i am not hitting the wrong nail :(

    Thanks: ~Yogendra

  • Hi Chas49,


    I recall running into the same issue, but can not remember exactly what it was. This is the IF statement I now use:


    If UserForm1.CheckBox4.Value = True Then
    Range("_2.5").Show
    Else
    Application.Goto Reference:="_2.5"
    Range("_2.5").Rows.Hidden = True
    End If


    Hope it helps,


    Ed

  • ED:


    You set me off on the right line and the following works OK.........


    If ws4.Cells(6, 2).Value = Empty Then
    ws3.Range("d14:e14").Rows.Hidden = True
    Else
    ws3.Range("d14:e14").Rows.Hidden = False
    End If



    yjoshi:


    Even unprotected it wouldn't work for me in it's original form.


    Thanks to both for your efforts.

    Les

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!