View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Weird Cell Behaviour

Darn fingers!

First, I think I would have used:

Range("G1").FormulaR1C1 = "=count(R5C4:R65000C4)"

And this should count the number of cells that contain numbers--not just filled
with anything (text or formulas).

If you wanted anything, you could have used:

Range("G1").Formular1c1 = "=counta(R5C4:R65000C4)"

As for the descrepancy between the values, do you have calculation set for
automatic?

(Tools|Options|Calculation tab)





Matt wrote:

Guys,

I have the following formula:

Range("G1").Formula = "=count(R5C4:R65000C4)"

Which counts filled cells in column D. It comes to the right result of
27, which is then displayed on the cell. (G1)

I then pick this value up into a variable for further calculations
which were wrong...

Tq = Range("G1").Value

So I checked the value of the variable Tq:

Range("g2").Value = Tq

and it gives 1362 ... I wonder how this is?

Also when i have the macro paste special values G1 into G1 it goes from
27 (correct) to 1362 (wrong).

What am I doing wrong?

Matt


--

Dave Peterson