Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am having hard time with retrieving range.address which is longer than 255 characters. My range consists of multiple fragmented ranges, its address looks like this: "A1:B3, C4, K7:T6, A3:D3"

Currently I am working on a range with address longer than 1000 characters. The sad thing is I have not been able to get the full address with range.address. I got only 255 first character.

Any help is appreciated :)

By the way, I have read Microsoft's work around on passing string longer than 255 chars at http://support.microsoft.com/kb/105416 . But that's about passing string, not about returning string, so...yeah.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

I didn't realize that there are limitation in range address length. Similarly to @Rory solution I loop through range areas but my solution uses function which returns long address string.

Function LongSelectionAddress(rngToGetAddress As Range) As String
    Dim LongAddress As String, rngArea As Range

    For Each rngArea In rngToGetAddress.Areas
        LongAddress = LongAddress & rngArea.Address & ","
    Next rngArea

    LongSelectionAddress = Left(LongAddress, Len(LongAddress) - 1)
End Function

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...