Human_doing
Board Regular
- Joined
- Feb 16, 2011
- Messages
- 137
Hi all,
Can anyone please help with this. What I'm trying to do is use VBA to place a formula in every cell in Column B where there is an entry in the adjacent Column A. The number of used rows may vary every time. Could anyone please correct the below code? The required formula is
=COUNTIF($A$2:$A2,A2)>1
The error I get is Run-time error 91: Object variable or With block variable not set.
Many thanks
Can anyone please help with this. What I'm trying to do is use VBA to place a formula in every cell in Column B where there is an entry in the adjacent Column A. The number of used rows may vary every time. Could anyone please correct the below code? The required formula is
=COUNTIF($A$2:$A2,A2)>1
Code:
Dim Sh As Worksheet
Dim LR2 As Long
With Sh
LR2 = .Range("A" & .Rows.Count).End(xlDown).Row
.Range("B2:B" & LR2).Formula = "=COUNTIF(R2C1:RC1,RC[-1])>1"
End With
The error I get is Run-time error 91: Object variable or With block variable not set.
Many thanks
Last edited: