简体   繁体   中英

How to get data from concatenated strings in one cell to another table in Google Sheets?

for my use case, I have a Google survey that is connected to a main Google Sheet .

The survey has a 2 questions: 1. Name, 2. Multiple Choice from 1-31 (days of a month). My survey results come into a by Google survey/Forms automatically generated table in Google Sheets with 2 columns: 'Name', and 'Which days?'. The 'Which Days?' column is has cells with a concatenated list of strings (eg '1, 3, 6, 8, 11').

The main Google Sheet has following structure: The first column is 'Name' that just imports the name from the Typeform Sheet (this works fine). The remaining columns represent the days of the month (so up to 31 columns from 1-31). Under each column, there are checkboxes.

The idea is that the checkboxes will automatically check according to the results from the Typeform (instead of checkboxes, we could also use colored cells if that is easier).

The problem : How can I automatically get the data from the concatenated cell 'Which Days?' (eg '1, 3, 6, 8, 11') to the main Google Sheet (so that columns '1', '3', ..., '11' are checked/colored)?

Thank you!

You can use this formula on cell B2 of your main sheet (assume Sheet1 is your survey sheet and Sheet2 is your main sheet):

=IF(iferror(match(CELL("address",B2),ARRAYFORMULA(ADDRESS(ROW(B2),1+split(Sheet1!$B2,","))),0),0),TRUE,FALSE)

Then drag right and down to the end of the table.

Sample:

在此处输入图片说明

在此处输入图片说明

Explanation:

SPLIT creates an array of numbers based on your input delimited by commas.

ADDRESS creates a string of cell references. ARRAYFORMULA extends this to an array.

MATCH returns a valid value if the CELL reference of the cell position exists on the other table, else it will return error.

IF and IFERROR will return true or false depending on the value of MATCH.

use:

=ARRAYFORMULA(REGEXMATCH(COLUMN(B:K)-1&"", 
 "^"&SUBSTITUTE(SUBSTITUTE(IFNA(VLOOKUP(A10:A12, A1:B3, 2, 0)), " ", ), ",", "$|^")&"$"))

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM