Hello,
I have this code that I want to change so that it automatically finds the last row.
I have used
but I can't get it into my code.
Can anyone help me?
I have this code that I want to change so that it automatically finds the last row.
VBA Code:
Sub Hide_Rows_With_0_in_Column_F()
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.Calculation = xlManual
Dim iRow As Range, rngLoop As Range
For Each ws In ThisWorkbook.Worksheets
Select Case ws.Name
Case "K1"
Set rngLoop = ws.Range("8:50").Rows
For Each iRow In rngLoop
If iRow.Cells(6) <= 0 Then
iRow.Hidden = True
End If
Next iRow
Case "K2"
Set rngLoop = ws.Range("8:150").Rows
For Each iRow In rngLoop
If iRow.Cells(6) <= 0 Then
iRow.Hidden = True
End If
Next iRow
Case "K3"
Set rngLoop = ws.Range("8:650").Rows
For Each iRow In rngLoop
If iRow.Cells(6) <= 0 Then
iRow.Hidden = True
End If
Next iRow
Case "K4"
Set rngLoop = ws.Range("8:500").Rows
For Each iRow In rngLoop
If iRow.Cells(6) <= 0 Then
iRow.Hidden = True
End If
Next iRow
Case "K7"
Set rngLoop = ws.Range("8:400").Rows
For Each iRow In rngLoop
If iRow.Cells(6) <= 0 Then
iRow.Hidden = True
End If
Next iRow
Case Else
End Select
Next ws
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub
I have used
VBA Code:
lastRow = ws.Cells(ws.Rows.Count, “A”).End(xlUp).row
Can anyone help me?