MultipleAnswer(MA)をSingleAnswer(SA)に変換するマクロ
該当項目の選択肢番号を、複数項目回答させたデータを0/1に変換する。
1:猫 2:牛 3:虎 4:兎 5:蛇
例:3,5 → 00101
Dim MA2SA As Variant Dim i As Long Dim j As Long For i = 4 To 100'読み込む行範囲 If Cells(i, 2) <> "" Then 'MA回答が2列目にあるときのケース MA2SA = Split(Cells(i, 2), ",") '区切りは"," Range(Cells(i, 3), Cells(i, 12)) = 0 '選択肢が10あるケース。結果はMA回答のすぐ右(3列目)から10セルに記入。0で初期化 For j = 0 To UBound(MA2SA) Cells(i, Val(MA2SA(j)) + 2) = 1 '3列目から記入するための+2 Next j Else Cells(i, 2) = "nothing" End If Next i End Sub
反省と今後
・SA2MAも考えよう。
・