VBA error "wrong number of arguments or invalid property assignment"

fmxwannabe

New Member
Joined
Jun 24, 2013
Messages
24
Hi all,
Hoping somebody can help me why I am getting the error "wrong number ofarguments or invalid property assignment"?
' .Replace "T20", "T21", "T22","T31", "T32", "T40", "T50","T60", xlWhole'
If I change to one search condition it works, but with multiple it fails. Can somebody see where i am going wrong?

Thanks,



Code:
Option Explicit
Sub Delete_Based_on_Criteria()
    Dim lngRowStart As Long, _
        lngRowEnd As Long
    Dim strCol As String, _
        strSheetName As String
    
    lngRowStart = 2
    strCol = "A"
    strSheetName = "Sheet1"
    
    Application.ScreenUpdating = False
    With Sheets(strSheetName)
        lngRowEnd = .Cells(Rows.Count, strCol).End(xlUp).Row
        If lngRowEnd > lngRowStart Then
            With .Range(strCol & lngRowStart & ":" & strCol & lngRowEnd)
                .Replace "T20","T21","T22","T31","T32","T40","T50","T60", xlWhole
                On Error Resume Next ' Account for no cells from the array being found.
                    .SpecialCells(xlCellTypeConstants, xlErrors).EntireRow.Delete
                On Error GoTo 0
            End With
        End If
    End With
    
    Application.ScreenUpdating = True
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
The first two arguments are what to replace, and what the replacement is. You can only specify one value for each.
 
Upvote 0
Either use multiple Replace statements or a loop.
 
Upvote 0
What do you want the strings replaced with?
 
Upvote 0

Forum statistics

Threads
1,215,254
Messages
6,123,893
Members
449,132
Latest member
Rosie14

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