snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Private Sub CommandButton1_Click()
Row = 1
Do
Row = Row + 1
Loop Until Worksheets("รายการสินค้า").Cells(Row, 1) = ""
Worksheets("รายการสินค้า").Cells(Row, 1) = TextBox1
TextBox1 = ""
If OptionButton1.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton1.Caption
Else
If OptionButton2.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton2.Caption
End If
If OptionButton3.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton3.Caption
End If
If OptionButton4.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton4.Caption
End If
If OptionButton5.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton5.Caption
End If
If OptionButton6.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton6.Caption
End If
If OptionButton7.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton7.Caption
End If
If OptionButton8.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton8.Caption
End If
If OptionButton9.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton9.Caption
End If
If OptionButton10.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton10.Caption
End If
If OptionButton11.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton11.Caption
End If
If OptionButton12.Value Then
Worksheets("รายการสินค้า").Cells(Row, 2) = OptionButton12.Caption
End If
End If
OptionButton1.Value = 0
OptionButton2.Value = 0
OptionButton3.Value = 0
OptionButton4.Value = 0
OptionButton5.Value = 0
OptionButton6.Value = 0
OptionButton7.Value = 0
OptionButton8.Value = 0
OptionButton9.Value = 0
OptionButton10.Value = 0
OptionButton11.Value = 0
OptionButton12.Value = 0
Worksheets("รายการสินค้า").Cells(Row, 3) = ComboBox1
ComboBox1 = ""
Worksheets("รายการสินค้า").Cells(Row, 4) = ComboBox3
ComboBox3 = ""
Worksheets("รายการสินค้า").Cells(Row, 5) = TextBox3.Value
TextBox3 = ""
Worksheets("รายการสินค้า").Cells(Row, 6) = Now()
Worksheets("รายการสินค้า").Cells(Row, 7) = Now()
Worksheets("หน้าแรก").Cells (ListBox1)
End Sub