Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

range object

Status
Not open for further replies.

matrixknow

IS-IT--Management
May 3, 2007
78
The COUNTIF works, when I use a fixed range ("A1:A100"). The range should be a variable and I use an range object. However, it types it literaly "(range1, E3)" and not eg ("A1:A156") and the formula gives an error "#Name?".

Code:
 Set range1 = Sheet20.Range("E3:E" & LastRow)
   Sheet20.Range("D3:D" & LastRow).Formula = "=IF(COUNTIF(range1,E3)>1,""D"",""F"")"

How do I need to write this ?
 
Use range1.Address (with parameter if necessary) to build the string.

combo
 
As per Combo's reply, the FORMULA property takes a STRING so "range1" is interpreted literally. You must insert the address as part of the string:

"=IF(COUNTIF(" & range1.address & ",E3)>1,""D"",""F"")"


Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top