How to use array in below code to find multiple strings?
Sub Replace18()
Dim rng As Range
Dim rws As Long
rws = Range("A" & Rows.Count).End(xlUp).Row - 3
Set rng = Rows("3:3").Find(What:="quantity", LookAt:=xlWhole, MatchCase:=False)
If Not rng Is Nothing Then
rng.Offset(1, 0).FormulaR1C1 = "20"
rng.Offset(1, 0).Resize(rws).FillDown
End If
End Sub
another variant (based on
@Jeeped
answer)or
Set up a variant array and cycle through them.
I've modified your search for the 'last row' to include all columns with the Range.SpecialCells method using the xlCellTypeLastCell option. This works best with a properly referenced parent worksheet which I've included in a With ... End With block. All cell and range references within this block should carry a period (aka
.
or full stop) as a prefix to note that they belong to the worksheet referenced in the With ... End With. This includes.Rows(3)
just as the.Find
uses a prefix period to note that it is referencingRows(3)
.