Macro modification

Jeeremy7

Board Regular
Joined
May 13, 2020
Messages
110
Office Version
  1. 365
Platform
  1. Windows
Hello I have this macro

VBA Code:
Sub Delete_Duplicate_Codes_AURA_Data()

   'Delete amount already invoiced last month
    Const F = "F7:F#&""¤""&G7:G#"
    Dim V, R&
    With Sheet10
        V = Filter(.Evaluate(Replace("TRANSPOSE(IF(F7:F#>""""," & F & "))", "#", .Cells(.Rows.Count, 6).End(xlUp).Row)), False, False)
    End With
    With Sheet7
        V = Application.Match(.Evaluate(Replace(F, "#", .Cells(.Rows.Count, 6).End(xlUp).Row)), V, 0)
        Application.ScreenUpdating = False
    For R = UBound(V) To 1 Step -1
        If IsNumeric(V(R, 1)) Then .Rows(R + 6).Delete
    Next
        Application.ScreenUpdating = True
    End With
    
    Range("A1").Select
    
End Sub

I would like the line not be deleted if the data in column 6 is ''XXX''' I think the problem is to add a exception at If IsNumeric(V(R, 1)) Then .Rows(R + 6).Delete but I'm not sure how to ?

Thanks !
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
VBA Code:
For R = UBound(V) To 1 Step -1
       If V(R, 6) <>"XXX" Then
             If IsNumeric(V(R, 1)) Then .Rows(R + 6).Delete
       End If
Next

Not sure if it will solve your issue but hoping at least the concept might give you an idea.
 
Upvote 0
I get a compile error Next without for
VBA Code:
Sub Delete_Duplicate_Codes_AURA_Data()

   'Delete amount already invoiced last month
    Const F = "F7:F#&""¤""&G7:G#"
    Dim V, R&
    With Sheet10
        V = Filter(.Evaluate(Replace("TRANSPOSE(IF(F7:F#>""""," & F & "))", "#", .Cells(.Rows.Count, 6).End(xlUp).Row)), False, False)
    End With
    With Sheet7
        V = Application.Match(.Evaluate(Replace(F, "#", .Cells(.Rows.Count, 6).End(xlUp).Row)), V, 0)
        Application.ScreenUpdating = False
    For R = UBound(V) To 1 Step -1
        If V(R, 6) <> "XXX" Then
        If IsNumeric(V(R, 1)) Then .Rows(R + 6).Delete
    Next
        Application.ScreenUpdating = True
    End With
    
    Range("A1").Select
    
End Sub
 
Upvote 0
you are missing "End If"

VBA Code:
If V(R, 6) <> "XXX" Then
        If IsNumeric(V(R, 1)) Then .Rows(R + 6).Delete
End If
 
Upvote 0
oups....
Now it tells me
Run-time error 9
Subscript out of range ?

VBA Code:
    Const F = "F7:F#&""¤""&G7:G#"
    Dim V, R&
    With Sheet10
        V = Filter(.Evaluate(Replace("TRANSPOSE(IF(F7:F#>""""," & F & "))", "#", .Cells(.Rows.Count, 6).End(xlUp).Row)), False, False)
    End With
    With Sheet7
        V = Application.Match(.Evaluate(Replace(F, "#", .Cells(.Rows.Count, 6).End(xlUp).Row)), V, 0)
        Application.ScreenUpdating = False
    For R = UBound(V) To 1 Step -1
        If V(R, 6) <> "Josh Visa RBC" Then
        If IsNumeric(V(R, 1)) Then .Rows(R + 6).Delete
        End If
    Next
        Application.ScreenUpdating = True
    End With
    
    Range("A1").Select
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top