+ Reply to Thread
Results 1 to 3 of 3

a macro that looks up two rows of data and selects cells based on a certain condition

  1. #1
    Registered User
    Join Date
    03-15-2010
    Location
    London,
    MS-Off Ver
    Excel 2007
    Posts
    20

    a macro that looks up two rows of data and selects cells based on a certain condition

    Hello

    I have two rows of data. In row 1, I have year1, year2, year3 etc. Directly underneath in row 2, some cells contain numbers and some contain N/A. What I want to do is create a macro that will look up the values in row B, select only those cells that contain numbers and set the range equal to x. Then I want it to select the cells in row A that correspond to the cells in row B that contain numbers, and set this range equal to y. This is so I can make a line graph of x against y. Does anyone have any idea on how to do this? I've attached a workbook with some numbers if it makes things clearer.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: a macro that looks up two rows of data and selects cells based on a certain condi

    You would be better served, IMO, with the data placed in two columns and then use AutoFilter to hide the rows the #N/A values. Excel does not plot hidden rows or columns. No macro code is required. (You can keep your current format if and hide columns manually - placing the data into rows facilitates hiding using AF).

    See attached.
    Attached Files Attached Files
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    03-15-2010
    Location
    London,
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: a macro that looks up two rows of data and selects cells based on a certain condi

    that is a good suggestion, but the problem is, in the second row of data it may be that cells 1-5 contain numbers and the rest are N/A, or cells 5-12 contain numbers and the rest are N/A etc. It will change, so I wanted to avoid having to do something manual, which with the filter would mean reselecting the values that I want to show.

+ 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