I have this code that goes through rows and checks for duplicates. If there is a duplicate if should hide the row. But somewhy it doesn't hide it.
Function sumAll()
Dim firstRow As Long
firstRow = 5
Dim lastRow As Long
lastRow = 1424
Dim aRow As Long
Dim totalDoubles As Long
totalDoubles = 0
Dim sumResult As Double
sumResult = 0
Dim previousValue As String
previousValue = -1
For aRow = firstRow To lastRow
If Cells(aRow, 1).Value <> previousValue Then
sumResult = sumResult + Cells(aRow, 2)
previousValue = Cells(aRow, 1)
Cells(aRow, 1).EntireRow.Hidden = True
Else
totalDoubles = totalDoubles + 1
End If
Next aRow
sumAll = sumResult
MsgBox ("end: " & totalDoubles)
End Function
I also tried Sheets("Sheet name").Rows("5:5").EntireRow.Hidden=True but it gave no effect as well.
Sub sumAll()...End Sub. A function is a thing that takes parameters and returns a return value. What you're doing needs a sub. During a function execution you can not alter the worksheets / workbook.