I have a column(x) and trying to do a If and like in another column(d). Getting a range error on the selection autofill part.
Dim src As Range
Set src = Worksheets("File").Range("2:17783")
If (Range("x2").Value Like "*ProductType:'FXD';*") Then
Range("D2").Value = "FXD"
ElseIf (Range("x2").Value Like "*;ProductSubType:'SWLEG'*") Then
Range("D2").Value = "XSW"
End If
Selection.AutoFill Destination:=src.Columns("D")
Instead of doing autofill just set the value at once.
Also do not forget to provide the sheet parent to all your range objects:
Dim src As Range
Set src = Worksheets("File").Range("2:17783")
If (Worksheets("File").Range("x2").Value Like "*ProductType:'FXD';*") Then
Worksheets("File").Range("D2:D17783").Value = "FXD"
ElseIf (Worksheets("File").Range("x2").Value Like "*;ProductSubType:'SWLEG'*") Then
Worksheets("File").Range("D2:D17783").Value = "XSW"
End If
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With