View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
CAPTGNVR CAPTGNVR is offline
external usenet poster
 
Posts: 115
Default ASSIGNING THE VALUE TO A NAMED RANGE GIVING OBJECT DEFINED ERROR

On Feb 16, 11:48 pm, "Don Guillett" wrote:
Maybe I'm missing something. Try

Sub countcolf()
range("REF_NUMBR").value= Application.CountA(range("f5:f20"))
End Sub

--
Don Guillett
SalesAid Software
"CAPTGNVR" wrote in message

ups.com...

DEAR ALL


I intended to use the result of RCOUNT variable to various other
procedures.


So I have named a cell by name REF_NUMBR.


Flg is the vb code:
Set COL_F = Range("F5.F20")
RCOUNT = Application.CountA(COL_F)
100 Names("REF_NUMBR").Value = RCOUNT


but at line 100 it gives error saying application-defined or object-
defined error.
Then I made it as activeworkbook.Names("REF_NUMBR").Value = RCOUNT
and it accepts.


Instead of the above if i use Range("REF_NUMBR").Value = RCOUNT
it takes the value.


Earlier i was using activesheet.range("a1").value = RCOUNT and was
referring to this range.


Pls advice how to use the line 100 correctly using the 'NAMES' and
shortest code.


Thnk u Don. Actually i find it difficult to put it down in writing in
this forum. Luckily i got the answer from Mr. Dave. I wanted to know
how to use the Name property as i was getting error when i use. Now
this thread i can consider closed once i get from Dave how to set a
variable to the whole line defining the range.