EirikDaude
09-01-2017, 01:14 AM
I have a worksheet in which I clean up some raw data. In it there are a few different loops which are supposed to delete rows, e.g.
Sub fjern_ugyldige_verdiar(sluttpunkt As Long, ws As Worksheet)
Dim i As Long
For i = sluttpunkt To 1 Step -1
If Not IsNumeric(ws.Range("B" & i)) Then
ws.Rows(i).Delete
End If
Next i
End Sub
and
Sub rydd_i_månadsmålingar()
Dim i As Long, j As Long
With Månads
...
For j = i To 1 Step -1
If .Range("B" & i) = 0 Then
.Rows(i).Delete
End If
Next j
End With
End Sub
Now, the problem is that the first one actually deletes the rows while the latter doesn't. I have checked that I loops over the correct range, and that the sub enters the if-statement - both of these are the case, so I am stumped why the rows aren't deleted from the sheet. Do any of you guys have some input on what might be the problem here.
The raw data is pasted into the sheet "Enkeltmålingar" and the macro is then run by clicking the button near the top.
20220
Sub fjern_ugyldige_verdiar(sluttpunkt As Long, ws As Worksheet)
Dim i As Long
For i = sluttpunkt To 1 Step -1
If Not IsNumeric(ws.Range("B" & i)) Then
ws.Rows(i).Delete
End If
Next i
End Sub
and
Sub rydd_i_månadsmålingar()
Dim i As Long, j As Long
With Månads
...
For j = i To 1 Step -1
If .Range("B" & i) = 0 Then
.Rows(i).Delete
End If
Next j
End With
End Sub
Now, the problem is that the first one actually deletes the rows while the latter doesn't. I have checked that I loops over the correct range, and that the sub enters the if-statement - both of these are the case, so I am stumped why the rows aren't deleted from the sheet. Do any of you guys have some input on what might be the problem here.
The raw data is pasted into the sheet "Enkeltmålingar" and the macro is then run by clicking the button near the top.
20220