Sign in to join the conversation:
Hi is there a function that can return the column number when given the column name? This would help when columns are added in sheets that have vlookups referencing them.
Hi,
Interesting question! I'd suggest you get used to using INDEX & MATCH instead of VLOOKUP as it is much more powerful and gives you greater control of your data. It also eliminates the silly need VLOOKUP has for you to define a column number to return. INDEX looks anywhere you tell it, including columns to the left of the data you are matching.
Consider the VLOOKUP formula:
=VLOOKUP(search_value, lookup_table,column_num, [match_type])
against the corresponding INDEX/MATCH formula:
=INDEX([range of return values], MATCH(search_value, lookup_table, [match_type]))
They are similar, but INDEX just finds the value you're asking it to as you're essentially giving Smartsheet coordinates to find a value. This eliminates the fuss of specifics (that may be changed by users). The key differences are:
Unfortunately Smartsheet does not allow you to access the column names, so you're somewhat stuck if you want to find a column position using that criteria.
Awesome Chris - great advice!! Could you give an example?
I've tried this:
=INDEX({DOC1' Range 13}, MATCH($[Column2]$2, {DOC1'}, false))
but it's not working.
Not sure what you put after INDEX?
Now what if we add a line to the document - how can we make sure it includes it to? Can we do without having to select a "range"
Hi Chris
We need this functionality. When doing a lookup or index match to another sheet, we need to dynamically reference a column.
=VLOOKUP(search_value, MATCH({Column Name, lookup_table, [match_type]), [match_type])
Is there any plan to provide this functionality?
Hi @yidnek
There's a workaround for this.
What you can do is have your first row on your sheet display all the columns names. within them. Then use a MATCH function looking for the column name and the range being only Row 1. This will return the number of the column you need for.
And you can perfectly include this in your VLOOKUP formula as the column reference (and you can also include this as the column reference in an INDEX/MATCH lookup.
Hope it helped!
I am wanting to do something similar with INDEX MATCH. I need to use MATCH to return the row number and the column number.
I can get it to return the row number, but I'm having trouble with the second MATCH to return the column number.
Since Smartsheet doesn't have the ability to reference column headers, I've duplicated the headers on ROW 1 of the source/referenced sheet.
=INDEX({Addresses}, MATCH([Mailing Instructions]@row, {MailingInstructions}, 0), MATCH("Address Line 1", {FedEx Address List Range 2}, 0))
Unfortunately, I'm getting the #INVALID VALUE error.
I know when I use this formula in Excel, I have to press CTRL+SHIFT+ENTER. Otherwise I get the #VALUE! error in Excel. Is there an equivalent step in Smartsheet to get this formula to work?
@Tori Isbell To get your formula to work
"Address Line 1" would need to be in Row 1, and {FedEx Address List Range 2} would have to be referencing Row 1.
You would also need to ensure that the {Addresses} range covers all of the columns.
This particular error is telling us that either the MATCH for the row number or the MATCH for the column number is returning a number that is either higher than the number of rows in the {Addresses} Range or higher than the number of columns within the {Addresses} range (or both).
To test this, use each of the MATCH functions as standalone formulas to see what numbers they return. You can then double check to verify that the {Addresses} range covers everything.
Hello! I have this formula that will check the box if the date in a second column is in the past. Is there a way to include if the date is 60 days in the future? Check the box if the date in Column 2 is either (1) in the past or (2) 60 days in the future. IF([GWO - BST (2yr)]@row < TODAY(), 1, 0) Thank you in advance!
Is there a way to automatically update my dropdown list for a form if I have a new item added? I have a New Order Entry form. I have a dropdown list of customers, but if it is a new customer, there is a checkbox to allow more fields to open up to enter that information. If that information is added, it gets copied to a…
Hi! I'm trying to figure out how to use the NETDAYS formula to show how long someone has been a member of a certain team. I can't get it to measure to today using the formula that the website suggests. I want it to be running so that whenever I log on I can see the time elapsed to the day I'm looking at the sheet. Can…