+ Reply to Thread
Results 1 to 7 of 7

Need to define dynamic range for column I to K based on dynamic column A

  1. #1
    Registered User
    Join Date
    05-22-2014
    Posts
    37

    Need to define dynamic range for column I to K based on dynamic column A

    I'm pretty new to VBA, so please be patient with me.

    I need to compare values in column I to K for the item (here: numbers) in column A. The different items in column A har different amount of properties, so for example;
    Item 12 has 30 properties, item 13 har 8 properties, item 14 has 20 properties.
    Along with the properties there are values (represented in column I to T). These values needs to be compared to a constant number (f.ex. all values higher than 100-> red color).
    BUT there are different criterias for the different items, f.ex; values for item 12A(I to K) gets red it alue is higher than 100, values for item 12B(L to N) gets red if value is higher than 500, value for item 13A(I to K) gets red if value is higher than 1000, and so on.

    The attachment shows 4 items (12 to 15), but this could be 100 items or 15 items, this list is variable (along with the properties to each item).

    How do I do this?
    Please see attachment to better understand the question .

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,943

    Re: Need to define dynamic range for column I to K based on dynamic column A

    You don't need VBA, but your do need to create a value table from which you can extract the limit for each combination of number and letter, as in this example, which uses a table in $V$9:$Z$13 and the CF formula (starting in I9)

    =I9>=INDEX($V$9:$Z$13,MATCH(MAX($A$9:$A9),$V$9:$V$13,FALSE),INT((COLUMN(I9)-9)/3)+2)



    Test CF example.xlsx
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    05-22-2014
    Posts
    37

    Re: Need to define dynamic range for column I to K based on dynamic column A

    Hi.
    Thanks, but this does not work if the number of properties (and therefore number of rows) under each item is changed/dynamic. I am supposed to delete tha whole data area (form A9 to T97 in this case) and replace it with datas for exaple from A9 to T400, and then the first item might consist of only 3 properties, or 20, or 45 (It can vary). And I want to just copy-paste the datas, and not have to set ut CF codes every time I get new datas.
    Thanks for helping anyway!

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,943

    Re: Need to define dynamic range for column I to K based on dynamic column A

    The CF is dynamic. Instead of just pasting and wiping out the formatting, simply paste values starting in column I (A through H can be a simple paste), and then copy the formatting of I9 down and over to match whatever range you have, and the CF will work with the entire range. You just have to have a big enough rules table. The one requirement, which appears to have been met by what you posted, is that the numbers in column A be in ascending order.

    Bernie
    Last edited by Bernie Deitrick; 12-18-2015 at 10:14 AM.

  5. #5
    Registered User
    Join Date
    05-22-2014
    Posts
    37
    Hi.
    Thanks, but I don't think this works. This workbook is a part of a macro creating the datas. So the numbers will be deleted and replaced with other numbers. If the CF codes refers to a range with 30 rows, and the new item after deletion/replacing bar 12 properties/rows, the rest of the rows (18 rows) will still be matched with the referenced number for the first item (and not the second as they should be), wouldn't they?
    This have to be adjusted automatically.
    This is also a smaller part in a "big plan"; to get the actual property of the number above a certain value inserted in another sheet (along with the number).

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Need to define dynamic range for column I to K based on dynamic column A

    How is this report generated? It looks like it is the result of a pivot table. At the moment, I am not sure if being able to see the source data would help or not. In any event, you will need a table off to the side to set the rules with Number and Letter and break point such as 12A:100, 12B:500, 12C:1000, etc. Can you provide us with such a table?

  7. #7
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,943

    Re: Need to define dynamic range for column I to K based on dynamic column A

    the rest of the rows (18 rows) will still be matched with the referenced number for the first item (and not the second as they should be), wouldn't they?
    No. The formula that finds the reference number is this part

    MAX($A$9:$A9)

    As the CF formula is copied down, that part changes to


    MAX($A$9:$A10)

    MAX($A$9:$A11)

    etc.

    So the reference number stays the value in A9 until another number is found, at which time it changes. That is why I said that the formula depends on the values in A being in ascending order: so that the MAX will work.

    Rather than saying "This doesn't work" without trying it, you should, rather, trust that the responses you get here will work - they may not fit exactly what you have, because only some of your requirements are actually communicated, but they will usually work and work really well. There are a lot of tricks and techniques that make Excel work easier and better, and the folks here (including me) have years and years of experience doing spreadsheets. I constantly learn neat things from reading the posts here - I started doing data analysis in Lotus 123 at least 30 years ago, so I have picked up a lot of knowledge along the way.
    Last edited by Bernie Deitrick; 12-19-2015 at 10:22 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Code to select dynamic range based on value in column A
    By tompee29 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2015, 05:28 AM
  2. [SOLVED] Using VBA to Reference a Dynamic Range based on Last Cell of an Adjacent Column
    By PW11 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-23-2014, 02:16 AM
  3. Dynamic Range Column Chart w/ Dynamic Avg Line (Excel 2007)
    By BrokenBiker in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 10-04-2012, 11:40 AM
  4. How do I set a dynamic range based on the column header?
    By gimiv in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2007, 03:25 PM
  5. Replies: 0
    Last Post: 02-28-2006, 09:10 PM
  6. Replies: 0
    Last Post: 02-28-2006, 09:10 PM
  7. Replies: 0
    Last Post: 02-28-2006, 09:10 PM

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