Converting Data into 0's and 1's = Excel 2003

Descent73

New Member
Joined
Apr 19, 2011
Messages
2
Hi,

Sorry if this has been posted before, first time poster.

I want to convert data from one way to another. Below are the examples:


ID Variable_A Variable_B Variable_C
1001 1
1002 2 5
1003 1 2
1004 2 3
1005 3 5 4
1006 1 2
1007 4
1008 5
1009 2 4

INTO:


ID Var_1 Var_2 Var_3 Var_4 Var_5
1001 1 0 0 0 0
1002 0 1 0 0 1
1003 1 1 0 0 0
1004 0 1 1 0 0
1005 0 0 1 1 1
1006 1 1 0 0 0
1007 0 0 0 1 0
1008 0 0 0 0 1
1009 0 1 0 1 0

If normally use this type of FORMULA:

=IF($B2=1,1,IF($C2=1,1,(IF($D2=1,1,0))))

Where B2 / C2 / D2 are the original data, but will have to copy this formula can change it for VARIABLE 2.

This isn't so much of a problem, until I have about 30 or MORE variables.

Is there anyway that this formula can be done quicker.

Thanks,
Descent73
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Perhaps something like
Excel Workbook
ABCDEF
1IDVariable_AVariable_BVariable_C
210011
3100225
4100312
5100423
61005354
7100612
810074
910085
10100924
11
12INTO:
13
1412345
15IDVar_1Var_2Var_3Var_4Var_5
16100110000
17100201001
18100311000
19100401100
20100500111
21100611000
22100700010
23100800001
24100901010
Sheet2
Excel 2007
Cell Formulas
RangeFormula
B16=IF(ISERROR(MATCH(B$14, $B2:$F2, 0)), 0, 1)
C16=IF(ISERROR(MATCH(C$14, $B2:$F2, 0)), 0, 1)
D16=IF(ISERROR(MATCH(D$14, $B2:$F2, 0)), 0, 1)
E16=IF(ISERROR(MATCH(E$14, $B2:$F2, 0)), 0, 1)
F16=IF(ISERROR(MATCH(F$14, $B2:$F2, 0)), 0, 1)
 
Upvote 0
In column B next to your index number in the first row use:

=IF(ISNUMBER(MATCH(COLUMN()-1,$B2:$H2,0)),1,0)

And copy down/across (if it is in a different place you just need to adjust the COLUMN()-1 bit of the formula to suit.

This works without a need to number your columns - you can extend the range B:H as far as you need to.
 
Upvote 0
B16,copy and across :

=--ISNUMBER(MATCH(COLUMN()-1, $B2:$F2,))

Regards
 
Upvote 0
In column B next to your index number in the first row use:

=IF(ISNUMBER(MATCH(COLUMN()-1,$B2:$H2,0)),1,0)

And copy down/across (if it is in a different place you just need to adjust the COLUMN()-1 bit of the formula to suit.

This works without a need to number your columns - you can extend the range B:H as far as you need to.
But is prone to error if new column(s) are subsequently added at the left of the sheet, as is the following:
B16,copy and across :

=--ISNUMBER(MATCH(COLUMN()-1, $B2:$F2,))

Regards
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,470
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top