Oct 25 2021 02:01 PM
Hello,
This is my first post here. Please let me know if this is correct!
Device: PC/Windows 10 Pro 64-bit (Version 21H1 Build 19043)
Excel version: Microsoft® Excel® for Microsoft 365 MSO (Version 2109 Build 16.0.14430.20154) 32-bit
Context: I’m a researcher at a university and am working to write some formulas that will simplify data entry. I don’t have much experience in Excel. Currrently, I’m looking at student extracurricular involvement on campus. While some students are involved in one activity, many are involved in multiple. I wrote an IF formula to convert a single value into a binary system that we can use for other stats software and skip cells where students didn’t answer anything. However, if a student is involved in more than one activity, the formula doesn’t recognize multiple values and I’ll need to go into each column by hand and enter either a “1” if they are involved or a “0” if they aren’t. The sample file attached demonstrates this.
Expected result and method: Write a formula that can identify one or more values in a single cell and correctly “code” those values with either a 1 or a 0 in the subsequent columns.
Oct 25 2021 02:18 PM
SolutionIn B2:
=IF($A2="","",--ISNUMBER(FIND(","&COLUMN()-1&",",","&$A2&",")))
Fill to the right, then down (or vice versa) as far as needed.
See the attached version.
Oct 25 2021 02:29 PM
Oct 25 2021 02:40 PM
As variant
=LET(
n, MID( A10, SEQUENCE(, LEN(A10)),1 ),
j, --FILTER(n, n <> ","),
IF( ISNA( XMATCH( SEQUENCE(,7),j )), 0, 1)
)
Oct 25 2021 08:25 PM
Oct 25 2021 08:27 PM
Oct 25 2021 08:28 PM
Oct 25 2021 08:28 PM
Oct 25 2021 09:48 PM
Oct 26 2021 01:41 AM
Formulas in Excel do not return blank as a value, you may return empty string instead or any other symbols here
For example
=LET(
n, MID( A10, SEQUENCE(, LEN(A10)),1 ),
j, --FILTER(n, n<>","),
IF( ISNA( XMATCH( SEQUENCE(,7),j )), "", 1)
)
Oct 26 2021 03:26 AM
If the data are in column I instead of column A, I'd expect you would have to use COLUMN()-9 instead of COLUMN()-1 since column I is 8 columns to the right of column A, but the exact formula depends on the setup.
If you see a formula in the cell instead of its result:
Oct 25 2021 02:18 PM
SolutionIn B2:
=IF($A2="","",--ISNUMBER(FIND(","&COLUMN()-1&",",","&$A2&",")))
Fill to the right, then down (or vice versa) as far as needed.
See the attached version.