+ Reply to Thread
Results 1 to 4 of 4

picking cell from named range passed to vba

  1. #1
    Registered User
    Join Date
    07-27-2011
    Location
    maryland
    MS-Off Ver
    Excel 2003
    Posts
    5

    Unhappy picking cell from named range passed to vba

    I'm trying to pull data from different rows of 2nd and 3rd column based on two passed values I am matching in the first column. the match seems to work fine, but getting the corresponsing values out of the named range isn't. thoughts on what i'm doing wrong?

    One of the relevant lines is here:
    vol_percent = curves.Cells(vol_pointer - 1 + i, 2).Value

    The code for this entire array function follows:

    Please Login or Register  to view this content.

  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,258

    Re: picking cell from named range passed to vba

    Hello toddah,

    Welcome to the Forum!

    You code assumes the range passed into the function has at least 3 columns. Yet, you have no code to validate the incoming range's size in rows and columns. If you range comes up short in either rows or columns, you are going to have problems.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-27-2011
    Location
    maryland
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: picking cell from named range passed to vba

    Thanks Leith,

    Good point about ensuring range is the correct size. In the call I'm passing a named range that is 50 rows by 3 columns. The matches are returning the correct row numbers. The curve.cells return empty even though there is good data in columns 2 and 3 corresponding to the match row. Is there something wrong with this syntax?
    vol_percent = curves.Cells(vol_pointer - 1 + i, 2).Value

    Cheers,
    -Todd

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

    Re: picking cell from named range passed to vba

    Hello Todd,

    I don't see anything obvious. It would be easier to troubleshoot if you could post a copy of the workbook. Please remove or change any information of a personal nature or what your company might consider to be confidential. If you need to scale down the workbook then it should be faithful to original in data layout, formulas, and any VBA code. Please include before and after examples of the data along with any explanatory comments.

+ 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