• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

hide row/columns via VBA

Status
Not open for further replies.

Afarag

Member
Dears,

please i want vba code can help me to hide an rows say from row10 till row50 and other van hide columns ex: from H till M
 
Hi Afarag,

Here you go:

Code to hide rows
Code:
Sub HideRows()
ActiveSheet.Rows("10:50").Hidden = True
End Sub

Code to hide columns
Code:
Sub HideCols()
ActiveSheet.Columns("H:M").Hidden = True
End Sub

Regards!!
 
Clear it's hidden, okey can i click to the shape to hide then click to the same shape to reset it not hidden?
 
@Afarag

Here you go.
Code:
Sub HideUnhide_Columns()
    With Columns("H:M")
        If .Hidden Then
            .Hidden = False
        Else
            .Hidden = True
        End If
    End With
End Sub

Regards!!
 
I have several various columns to hide and when I put those addresses in the code I get a run-time error "13", type mismatch. Here's what mine looks like:

With Columns("d, f:h, k:m, q, t:ah")

Can you help, thanks
 
Ok, so I don't know anything about code, this is what I tried to write...doesn't work. I need a code that hide/unhide columns by clicking a button. And I need the same thing for rows with a filter on a particular cell in a column.

Sub ExtensionFees()
Sheet1.Range("d, f:h, k:m, q, t:ah").EntireColumn.Hidden = True
If .Hidden Then
.Hidden = False
Else
.Hidden = True
End If
End With
End Sub

If this is too much, tell me where to go!

Thanks
 
test and modify this
Code:
Sub UnHideColsAndRows()
    Range("D:D,F:F,G:G,I:I,J:J").EntireColumn.Hidden = Not Range("D:D").EntireColumn.Hidden
    Range("2:3, 5:9").EntireRow.Hidden = Not Range("2:2").EntireRow.Hidden
End Sub
 
Status
Not open for further replies.
Back
Top