+ Reply to Thread
Results 1 to 4 of 4

Why Should This Code Fail?

  1. #1
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315

    Why Should This Code Fail?

    Can anyone explain why the following code (counting characters in a range) returns an error (2029)?

    Sub CountChar()
    set rng - ActiveSheet.Usedrange
    rng.select
    x = Evaluate("sum(Len(Selection)")
    MsgBox x
    End sub

    Ps: The array is correctly evaluated when a definite range (say "a1:d10" is substituted for selection.

  2. #2
    Registered User
    Join Date
    04-29-2004
    Posts
    92
    Sub CountChar()
    set rng - ActiveSheet.Usedrange '---this
    rng.select
    x = Evaluate("sum(Len(Selection)")
    MsgBox x
    End sub


    set rng = activesheet.usedrange

  3. #3
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315
    Sorry for the typographical error which was in any case not present in my original code. The error 2029 is still returned.

  4. #4
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Sub CountChar()
    Set rng = ActiveSheet.UsedRange
    x = Evaluate("=sum(Len(" & rng.Address & "))")
    MsgBox x
    End Sub

    - Mangesh

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1