VBA/Excel Help Needed

pjoub06

Senior Member
Joined
Aug 4, 2007
Messages
575
Reaction score
2
Location
Cape Town
Hello people,

This might be in the wrong section but please bear with me.Basically I'm trying to use VB to add a formula to the the H column. So what I want is Cells H2 to H(NoDupes.Count+1) to have the formula that says =countif($A:$A,G(i+1)) where i keeps changing in the for loop.
I get a "expected end of statement error at the "G" part in my formula. Anyone have any ideas what I'm doing wrong.


This is the for loop

For i = 1 To NoDupes.Count
Range("H" & (i + 1)).Formula = "=COUNTIF($A:$A,"G" & (i+1) )
Next i

Thanks a lot
 
Try this. Haven't tested, just throwing it out there

For i = 2 To NoDupes.Count
Range("H" & i ).Formula = "=COUNTIF($A:$A,G" & i & " )"
Next i
 
I'm hoping you know what you did wrong at least. Coz that's the important part, is knowing your mistake to learn from it
 
Top
Sign up to the MyBroadband newsletter
X