Consulting

Results 1 to 3 of 3

Thread: Solved: Interesting...

  1. #1

    Solved: Interesting...

    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?

    [vba]Sub test()
    Dim i as Long
    For i=2 To 3000
    Range("A" & i).Value = Range("A1:A" & i).Height
    Next
    End Sub[/vba]
    Jimmy
    -------------------------------------------------
    The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.

  2. #2
    VBAX Regular
    Joined
    Jun 2009
    Posts
    10
    Location
    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.

  3. #3
    Bingo!

    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
    -------------------------------------------------
    The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •