Results 1 to 3 of 3

Define the last row for a macro

Threaded View

  1. #1
    Registered User
    Join Date
    12-11-2012
    Location
    cincinnati, ohio
    MS-Off Ver
    Excel 2010
    Posts
    43

    Define the last row for a macro

    Good afternoon everyone,

    I have been working at this for a while, trying to convert macros that I've used previously to define the last row in a set of data, and I can't seem to get it to work. What I want this to do is to find the last row with data, in any column out to column BZ, in it and define it at the last row to be used in place of "xyz" in the macro attached below. Incidentally, it is probably fairly obvious that I am new to VBA, if you have a suggestion about how to make this macro more efficient, I am open to suggestions!

    Thanks for your help!

    Private Sub cmdSort_Click()
        
        
        If chkFE = True Then
            For Each cell In Range("BC4:BCxyz")
                If UCase(cell.Value) <> "Fire Extinguisher" Then
                cell.EntireRow.Hidden = True
                End If
            Next
    
        End If
        
        If chkChem = True Then
            For Each cell In Range("BD4:BDxyz")
                If UCase(cell.Value) <> "Chem" Then
                cell.EntireRow.Hidden = True
                End If
            Next
    
        End If
            
        If chkFL = True Then
            For Each cell In Range("BE4:BExyz")
                If UCase(cell.Value) <> "FL" Then
                cell.EntireRow.Hidden = True
                End If
            Next
    
        End If
            
        If chkElec = True Then
            For Each cell In Range("BF4:BFxyz")
                If UCase(cell.Value) <> "Elec" Then
                cell.EntireRow.Hidden = True
                End If
            Next
    
        End If
            
        If chkFP = True Then
            For Each cell In Range("BG4:BGxyz")
                If UCase(cell.Value) <> "FP" Then
                cell.EntireRow.Hidden = True
                End If
            Next
    
        End If
            
        If chkLift = True Then
            For Each cell In Range("BH4:BHxyz")
                If UCase(cell.Value) <> "Lift" Then
                cell.EntireRow.Hidden = True
                End If
            Next
    
        End If
            
        If chkPPE = True Then
            For Each cell In Range("BI4:BIxyz")
                If UCase(cell.Value) <> "PPE" Then
                cell.EntireRow.Hidden = True
                End If
            Next
    
        End If
            
        If chkPS = True Then
            For Each cell In Range("BJ4:BJxyz")
                If UCase(cell.Value) <> "PS" Then
                cell.EntireRow.Hidden = True
                End If
            Next
    
        End If
            
        If chkSTF = True Then
            For Each cell In Range("BK4:BKxyz")
                If UCase(cell.Value) <> "STF" Then
                cell.EntireRow.Hidden = True
                End If
            Next
    
        End If
            
        If chkErgonomics = True Then
            For Each cell In Range("BL4:BLxyz")
                If UCase(cell.Value) <> "Ergonomics" Then
                cell.EntireRow.Hidden = True
                End If
            Next
    
        End If
        
        Loop
        
        Unload frmSort
    
    End Sub
    Last edited by rodrignj; 02-25-2013 at 10:24 AM. Reason: solved

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