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
Bookmarks