TEXTBOX1 button1 button2 button3
TEXTBOX2 button4 button5 button6
comanndobuton1
Private Sub CommandButton1_Click()
Dim cnt As Long
cnt = Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
If Me.OptionButton1 = True Then
Cells(cnt, 1) = Me.TextBox1
Else
Cells(cnt, 1) = ""
If Me.OptionButton4 = True Then
Cells(cnt + 1, 1) = Me.TextBox2
Else
Cells(cnt + 1, 1) = ""
End If
End If
If Me.OptionButton2 = True Then
Cells(cnt, 2) = Me.TextBox1
Else
Cells(cnt, 2) = ""
If Me.OptionButton5 = True Then
Cells(cnt + 1, 2) = Me.TextBox2
Else
Cells(cnt + 1, 2) = ""
End If
End If
If Me.OptionButton3 = True Then
Cells(cnt, 3) = Me.TextBox1
Else
Cells(cnt, 3) = ""
If Me.OptionButton6 = True Then
Cells(cnt + 1, 3) = Me.TextBox2
Else
Cells(cnt + 1, 3) = ""
End If
End If
End Sub
これで実行するとbutton1がtrueでありbutton4がtrueのように
bu2とbu5 bu3とbu6が一緒の時だけうまく以下なのですが
ご指摘いただけないでしょうか
End Ifの位置を変えてみたらどうでしょうか
If Me.OptionButton1 = True Then
Cells(cnt, 1) = Me.TextBox1
Else
Cells(cnt, 1) = ""
End If
If Me.OptionButton4 = True Then
Cells(cnt + 1, 1) = Me.TextBox2
Else
Cells(cnt + 1, 1) = ""
End If
お礼
有難うございました end ifの使い方でかわるんですね まだまだ勉強です