Hi, very new to vba and this forum, which has been very helpful.
I have some code that works perfectly but always gives a 'Run Time Error 13' and stops the macro from completing.
Any help please?
'Delete a row of data
Dim rngSrc As Range
Dim NumRows As Integer
Dim ThisRow As Integer
Dim ThatRow As Integer
Dim J As Integer
'Select rows to be deleted
Set rngSrc = Sheet2.Range("J1:J250")
NumRows = rngSrc.Rows.Count
ThisRow = rngSrc.Row
ThatRow = ThisRow + NumRows - 1
'Delete rows
For J = ThatRow To ThisRow Step -1
If Cells(J, "J") = "8" Then
Rows(J).Select
Selection.Delete Shift:=xlUp
DeletedRows = DeletedRows + 1
End If
Next J
Line in bold is always highlighted when debugged.
many thanks
I have some code that works perfectly but always gives a 'Run Time Error 13' and stops the macro from completing.
Any help please?
'Delete a row of data
Dim rngSrc As Range
Dim NumRows As Integer
Dim ThisRow As Integer
Dim ThatRow As Integer
Dim J As Integer
'Select rows to be deleted
Set rngSrc = Sheet2.Range("J1:J250")
NumRows = rngSrc.Rows.Count
ThisRow = rngSrc.Row
ThatRow = ThisRow + NumRows - 1
'Delete rows
For J = ThatRow To ThisRow Step -1
If Cells(J, "J") = "8" Then
Rows(J).Select
Selection.Delete Shift:=xlUp
DeletedRows = DeletedRows + 1
End If
Next J
Line in bold is always highlighted when debugged.
many thanks