Results 1 to 2 of 2

Thread: Code to hide rows in Excel

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2003
    Posts
    3

    Code to hide rows in Excel

    Hi,

    I'm looking to write a procedure using vb in Excel to hide all rows where the content of column B is "DELETED". Could anyone help with this please?

    Could the rowref property be used to solve this and if so could you give an example? Or could you help me with some code to move to the row below the current row in the spreadsheet, for example (in words):

    Do
    RowBelowProcedure:
    GoTo Next Row
    If cell in column B.value = "DELETED" Then
    hide row
    Else
    GoTo RowBelowProcedure
    Loop Until column B.value = ""

    Thanks.

  2. #2
    Addicted Member
    Join Date
    Aug 2003
    Location
    houston
    Posts
    185
    you could try something like this
    it will go for 64 rows but you need to be able to get that programatically
    but since i dont know your lay out ......


    assuming active cell is the col you want to seach thru
    Code:
    Public Sub hidedel()
       
    Dim c As Range
    Dim r As Range
    Dim lCols As Long
    lrows = 64
    
    Set r = Range(ActiveCell.Address, ActiveCell.Offset(lrows, 0).Address)
        
    For Each c In r
        If c.Value = "deleted" Then
        c.Select
        Selection.EntireRow.Hidden = True
        End If
    Next
    
    
        
        
    
    End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width