rsmeyerson
Board Regular
- Joined
- Nov 29, 2014
- Messages
- 104
Hello. I'm looking for some help. I would like to apply a formula to a specific sheet, column "R" if a specific name appears in column "B". I have tried the code below, but it is inserting the formula into column "R" for all rows, regardless of name.
Your help is appreciated.
Code:
With Sheets("RetailBack")
Dim a1 As Long, lstrw As Long
lstrw = .Range("A" & Rows.Count).End(xlUp).Row
For a1 = 2 To lstrw
If .Range("B" & a1).Value = "NAME1" Or .Range("B" & a1).Value = "NAME2" Then
.Range("R2:R" & .Cells(.Rows.Count, "A").End(xlUp).Row).FormulaR1C1 = "XX"
End If
Your help is appreciated.
Last edited: