+ Reply to Thread
Results 1 to 7 of 7

Return value based on a variable number of cells

  1. #1
    Registered User
    Join Date
    05-27-2018
    Location
    Los Angeles
    MS-Off Ver
    MS365 (Mac) Version 2021
    Posts
    30

    Return value based on a variable number of cells

    Hi there,

    This might be an impossible problem, so if it can't be done, i'm totally good with accepting that there just isn't a way of setting up the logic.

    Here's a small sample of an excel doc i've been working on/with for a few months. FMIL Experimental.xlsm
    I've managed to figure out logic and formulas for repeating headings and subheadings in columns in order to keep things organized and I've received help with VBA to affect font sizes. Everything that needs to work in a certain way works, but i had an idea that would save me a step, but it might be overly ambitious.

    In Column E, I have a "Page" column, which references the highlighted row (in the sample, it's "Drew Estate Acid" based on what's in cell A2, and then "Drew Estate Undercrown" based on cell A30. I did something similar with the "Grouping" in column F. All of this is set up so that an app plug-in for InDesign can group and keep the data organized for when i create a monthly catalog, and all of that is preamble to what I'd like to try to do.

    Column H is "Header Shield" and Column I is "Highlight. Generally, Header Shield will be based on one of the things (if any) in the highlight column. Essentially, if one of the items on the page is called out as being a "top seller" then i put "top seller" in the header shield column too, and that way the plug-in knows to both apply a color highlight to he row, and to delete all the headers except the one with the "top Seller" icon included in it. What i was thinking would be cool would be if the "header shield" column could automatically have "top seller" populate the Header Shield column if it appears in the highlight column. The problem is that i'm not quite sure how to make the formula look for "top seller" in the highlight column, but only within the items on that page (the columns under the page "Drew Estate Acid" have an example of how i've done it manually up until this point, and the shield header and highlight columns under "Drew Estate "Undercrown" are empty. Given that the number of items (and the number of subheadings) varies from "page" to "page", i can't just set a formula to look for the next "10-20 cells in column I, because 10-20 might not be enough, or it might bleed into the next "page" of items.

    Like i said, i'm not sure if this is even possible, and I haven't even been able to think of a way in which the logic could work. I'm hoping there's a ways to have the formula in column H look within a variable number of cells in column I (anything between highlighted rows) to see if any of them have a label like "top sellers" in them. Any ideas would be appreciated.

    Thanks everyone.

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

    Re: Return value based on a variable number of cells

    This may not be impossible if there is something that uniquely defines the characteristics of what constitutes a major Item#Input. This could be the color associated with the cell fill or the font, font size and type or maybe something as simple as that these cells are the only ones that are not clear filled. If you can confirm any of these characteristics let me know.

    I can envision an application that will first identify that, yes there is a major item input in this cell and this is the start row and this is the end row for that major item input.

    I am kind of lost on what you want to do after you get this information so let me rephrase it to see if I got it right. If anything in the highlight column (column I) has the string "Top Seller" you want to apply that string to everything in column H that is in the range for the major item input.

    I will warn you that any solution I come up with will use Excel Tables.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    05-27-2018
    Location
    Los Angeles
    MS-Off Ver
    MS365 (Mac) Version 2021
    Posts
    30

    Re: Return value based on a variable number of cells

    Quote Originally Posted by dflak View Post
    This may not be impossible if there is something that uniquely defines the characteristics of what constitutes a major Item#Input. This could be the color associated with the cell fill or the font, font size and type or maybe something as simple as that these cells are the only ones that are not clear filled. If you can confirm any of these characteristics let me know.

    I can envision an application that will first identify that, yes there is a major item input in this cell and this is the start row and this is the end row for that major item input.

    I am kind of lost on what you want to do after you get this information so let me rephrase it to see if I got it right. If anything in the highlight column (column I) has the string "Top Seller" you want to apply that string to everything in column H that is in the range for the major item input.

    I will warn you that any solution I come up with will use Excel Tables.
    Thanks for your help in this.

    The excel sheet that I'm building/using does use tables, and there is a "highlighted" row with a color fill, and bold white text. And you understand the ask exactly right.

    Essentially this is setup for a magazine that I design every month, and the brand/line name that I put in the page header gets a little icon for one of a few different possibilities like new items, top sellers, exclusives, etc… I figure, since I already manually ad one of those callouts to column I so that it can call out a specific item on that page, it would be cool if the header column could automatically pull from the highlight column.

    If you look at column H in the attached example (FMIL Experimental wFormulas.xlsm), you can see that I already have a formula that will keep repeating the info in the row above it until it hits two empty cells, and then stop. Right now, though, I have to just add some text to the first cell to give the other formulas something to keep repeating. I'm just trying to figure out the logic (or some specific formula) for it to look in Column I for anything, as long as it under that page heading (the color-filled row/repeated in column E)

    Hope this helps rather than making it more confusing.

    Thanks
    Last edited by JediDA; 01-19-2024 at 07:34 PM.

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

    Re: Return value based on a variable number of cells

    I think I understand the requirement. I'll give you a warning. I am entertaining company from out of town this week. I will relook at this issue when I get back from that responsibility. 8-{)}

  5. #5
    Registered User
    Join Date
    05-27-2018
    Location
    Los Angeles
    MS-Off Ver
    MS365 (Mac) Version 2021
    Posts
    30

    Re: Return value based on a variable number of cells

    Thanks for your help. Absolutely no rush. This is a "would be nice" thing, with no time limit. If it doesn't get used for the next issue of the magazine, it'll be used for the one after that, or the one after that. And like I said, I feel like it's much more of a logic problem than a technical limitation of excel problem, and I'm usually good at figuring those out, I'm just a little stuck this time. Again, I appreciate any help, so thank you.

    In the meantime, since I'm between deadlines at the moment, I took steps to be able to organize the records a bit better, and a side effect of that is that Column E now consistently lists the "page" without skipping any blanks. I'm still not quite sure how to use that, but I wanted to make sure the newest version was included in this thread. Also, for what it's worth, columns B-G are usually hidden because they're there more for organization or for other columns to reference.

    Full Month item listing Sample.xlsm
    Last edited by JediDA; 01-24-2024 at 06:48 PM.

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

    Re: Return value based on a variable number of cells

    I am ready to re-engage and I have some comments and some more questions.

    I don't think you have the differences for event modules like selection change or workbook open as compared with code in regular modules. That's OK. We'll straighten it out.

    You have a link to another workbook. You might want to import this data instead of linking to it. Power Query is exceptionally easy to work with. If you include a sample source data file. I will walk you through the steps to import data from it.

    The code you had on the Cigar sheet seems to be for the purpose of formatting the sheet. Well done. It gives me the insight to understand how to find the major headings.

    I am looking at the menu items sheet and it seems like you might want sheets for the other sections on this list as well. If your source data contain these sections, include some of that in your sample data.

    I can also see that there is some duplication of data. For example, the item description in column A is the same as the Item # in column B. I think I can come up with a more compact from. If my suspicions are correct, the source data might be amenable to a pivot table which will do most of the heavy lifting for us.

    I still have to go through the formulas you have in the various columns. Again, with the source data in mind, these might revert to lookups.

    So what I need from you is an explanation from how you get the original source data. A source data file with a good sample of data. It doesn't have to be the whole inventory just a good representation of it: enough records to in include a couple major sections and some sub and sub-sub sections under that. Explain the process you are using now to get the result you are using now.

    You have not scared me off yet.

    If the source data is in the format I think it is in, then what I can develop is a system where you save the raw data in the same directory with the same name every time overwriting the old data. As part of the data import process I can make an archive copy of the data if that is important. Then click on a button and all is done for you. I think I should be able to use a pivot table to sort things out by sections and do the major part of the formatting. Then I can sew it together with VBA code.

  7. #7
    Registered User
    Join Date
    05-27-2018
    Location
    Los Angeles
    MS-Off Ver
    MS365 (Mac) Version 2021
    Posts
    30

    Re: Return value based on a variable number of cells

    Hi, Sorry for the delayed response. I just finished with the most recent deadline so I'm now able to think about this again. You've nailed just about everything.
    • I link to an "inventory" workbook because, theoretically, the data (mainly pricing, but also new products/removing old products) changes every week or so. Most of the work done in this excel doc is because the raw item names in the inventory doc aren't really compatible with the magazine I create every month. So a lot of it is to keep the information accurate/up to date while also allowing me to completely change how the item is listed. Theoretically, we're changing to a new system over the next month or so, and hopefully enough of the information will be broken out over separate columns that I'll be able to automatically build item names the way they should be without having to change that part by hand.
    • I actually do have multiple sheets, each representing one category (cigars, non-cigar tobacco, alternative, accessories, etc…) I simply excluded any other sheets because they essentially all work the same way and I was trying to keep file-size reasonable.
    • The duplication is due to some limitations of the software that I use to connect Excel to InDesign. For the example that you referred to, column A cannot have any repeated data, so instance that some data needs to repeat, like a subhead/description for a 20 ct. box of Maduro, I add a space to the end of the line in column A so that the software doesn't kick it back. Column B, includes a "Trim" function to remove those spaces so they don't get in the way of any other lookup functions in the excel file or in the text boxes in the final InDesign file.
    • With all of that in mind, here's a quick rundown of the general setup. Column A includes item numbers, separated by "Page" (highlighted with a color fill and white 14pt. text) and "Grouping" (highlighted with bold text and a black stroke on the bottom of the row) which are then copied into column E and F respectively. Columns E, F, G, and H contain this information exclusively for being able to alphabetize the excel sheets and to allow InDesign to identify groups and subgroups. Column I and J (Header Shield & Highlight) pull from the same list in the "Menu Items" tab. Column J automatically highlights individual rows in Indesign to call out individual items, whereas Column I allows InDesign to see that a specific callout needs to be added to the header on the page. The way InDesign specifically looks at Column I to determine a header is by looking at the first item on the page, or in the case of a split page, the first and last item on a page. That's why column I needs to populate a single item from the list for the entire "page."
    • Ideally, what I would do for Column I is set up a series of if/then functions so that, if the first value is false, then look for the 2nd, etc… The first function would be to look at columns M and R. If M is not blank and R is not blank, that would mean that there's 2 promotions happening on the same page, a discount and a free gift, so the header for the page would be "2x Deals" from the list in the Menu Items tab. If that's false, then it would look at column I of any row that is on the same "page" (matching value of column E, if that makes sense). I'd probably continue setting up if/then functions so that there's a level of priority so that first it looks for "new" If it doesn't find that then "Top Seller" if not that then "limited" then "exclusive" etc…

    The issue that I'm having with setting up these header formulas is that it can't automatically look at the same row or the row directly above it. It needs to search all the rows where the values in Column E match, to see if there's one of the options in column J. Given all of the other logic I've been able to build in, I feel like I'm almost there, but not quite.

    The system won't allow for individual files over 1mb, so I'm attaching the full inventory report that my excel doc pulls from (Current Inventory.xlsx) but only a reduced version of the excel doc with my formulas, because in full it's about 15mb (Full Month item listing reduced.xlsm).

    Let me know if I can help clarify anything else.

    Thanks again.

+ 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. Replies: 6
    Last Post: 09-30-2020, 09:42 PM
  2. [SOLVED] Calculate average of variable number of cells variable number of times
    By WeirnetherlandsBart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2014, 10:11 AM
  3. [SOLVED] Return a number from a range of cells based on criteria?
    By Polymorpher in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-25-2014, 11:01 AM
  4. How to concatenate a variable number of rows/cells based on multiple criteria?
    By jonharadon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2012, 09:22 PM
  5. Replies: 2
    Last Post: 05-30-2012, 05:02 PM
  6. Omit cells based on variable row number
    By Steffen_DK in forum Excel General
    Replies: 5
    Last Post: 02-07-2012, 06:46 PM
  7. Need to merge variable number of cells into one single cell based on criteria
    By NewYorkVanilla in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-20-2009, 11:05 AM

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