Results 1 to 3 of 3

Hide blank columns via loop

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-12-2010
    Location
    Excel World
    MS-Off Ver
    Excel 2013, 2019 & O365
    Posts
    214

    Question Hide blank columns via loop

    Hi All,

    I've written below codes for automatically hiding blank columns via loop in the each worksheet of the current workbook, but it's not running well...

    Option Explicit
                'In a Module
    Sub HideColms()
    ' To automatically hide blank columns via loop
    '
    Dim colmRng As Range
    Dim ws As Worksheet
    
        ActiveSheet.Cells.EntireColumn.Hidden = False       ' To unhide the entire columns in the worksheet
        ActiveSheet.Cells.EntireRow.Hidden = False              ' To unhide the entire rows in the worksheet
    
        Range("E1").EntireColumn.Select
        Range(ActiveCell.EntireColumn, Selection.End(xlToRight)).Select
        Selection.ColumnWidth = 0.5
    
    Set colmRng = ActiveCell.EntireColumn.Offset(0, 1)
    
        Range("D1").Select
        For Each colmRng In ThisWorkbook.Worksheets
        colmRng.Select
        colmRng.Hidden = True
        Range("D1").Select
        Next
    
    End Sub

    Can anyone please help me and correct the codes??
    Last edited by SunOffice; 06-09-2011 at 02:39 AM.
    Excelforum is Completely Awesome! True learning with Live Examples & Best Techniques!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1