PDA

View Full Version : Solved: Interesting...



JimmyTheHand
06-29-2009, 01:12 AM
Hi Guys,

I've met a strange thing recently. Please run the code below on a new, empty worksheet, then look at the range around A3000. Looks like the total height of 2000 rows is the same as the total height of 3000 rows...
Any ideas why is this so?

Sub test()
Dim i as Long
For i=2 To 3000
Range("A" & i).Value = Range("A1:A" & i).Height
Next
End Sub
Jimmy

Dr Fear
06-29-2009, 03:55 AM
Height returns a variant according to the help, but clearly must be an integer in effect, and you've hit a limit.
I don't know why it hit a limit at 24575.25 though, I would have expected it to reach 32768.

JimmyTheHand
06-29-2009, 04:13 AM
Bingo! :clap:

You are right, of coure, I can see it now. And it's 24575.25 because there's a 3/4 factor in the system somewhere.
32767 * 3/4 = 24575.25

When you query the Height of a row, it gives you (by default) 12.75, but when you e.g. want to position the window to the 2nd row with ActiveWindow.ScrollIntoView, you need to use 12.75 * 4/3 = 17 instead.

Thanks

Jimmy