+ Reply to Thread
Results 1 to 5 of 5

Trouble with RSq function in VBA

Hybrid View

  1. #1
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Maybe capture the visible cell values in a pair of Variants, and then compute Rsq from those:

    Dim vX as Variant, vY as Variant, dR as Double
    
    vX = Sheets("Data").Range("aj3:aj1003").SpecialCells(xlCellTypeVisible).Value
    vY = Sheets("Data").Range("ak3:ak1003").SpecialCells(xlCellTypeVisible).Value
    R = WorksheetFunction.Rsq(vY, vX)

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello puckalicious,

    SHG's idea is a good one. The arrays will be faster and will overcome an inherent problem wih using "visible cells". The cells returned by "visible cells" are dependent on your filter and most likely are not going to contiguous. The cells used in RSQ must be contiguous, or it will throw an error. All the values in the arrays will be contiguous and not cause a problem.

    Sincerely,
    Leith Ross

+ 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