Change macro to hide row if null

K

krisminaz

I have a macro that works great but I want to tweak it a little. In
the macro below the Else value = NULL. Instead of a null result I want
to hide the entire row (or if a Null result then hide row). What do I
need to do?

Sub Process_CheckBox(pObject)

Dim LRow As Integer
Dim LRange As String

'Find row that checkbox resides in
LRow = pObject.TopLeftCell.Row
LRange = "B" & CStr(LRow)

'Change date in column B, if checkbox is checked
If pObject.Value = True Then
ActiveSheet.Range(LRange).Value = "=R2C1"

'Clear date in column B, if checkbox is unchecked AND HIDE ROW
Else
ActiveSheet.Range(LRange).Value = Null

End If

End Sub



Thanks!
Kris
 
D

Dave Peterson

Use a line like:
ActiveSheet.Range(LRange).entirerow.hidden = true
instead of (or along with) that "= null" line.

You may want to add:
ActiveSheet.Range(LRange).entirerow.hidden = false
to the then portion of that statement, too.
 
K

krisminaz

Use a line like:
ActiveSheet.Range(LRange).entirerow.hidden = true
instead of (or along with) that "= null" line.

You may want to add:
ActiveSheet.Range(LRange).entirerow.hidden = false
to the then portion of that statement, too.















--

Dave Peterson- Hide quoted text -

- Show quoted text -

Works like a charm! THANKS!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top