snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Private Sub Cancel_Click()
Unload Me
End Sub
Private Sub Clear_Click()
Call UserForm1_Initialize
End Sub
Private Sub namebox_Change()
Me.Caption = Namebox.Value
End Sub
Private Sub numberbox_Change()
Me.Caption = Numberbox.Value
End Sub
Private Sub OK_Click()
With Range("D3" & xlRows).End(xlUp).Offset(1, 0)
.Offset(0, 0).Value = Namebox.Value
If Buy.Value Then
.Offset(0, 1).Value = "¢ÒÂ"
Else
.Offset(0, 1).Value = "«×éÍ"
End If
.Offset(0, 2).Value = Pricebox.Value
.Offset(0, 3).Value = Numberbox.Value
End With
Namebox.Value = ""
Pricebox.Value = ""
Numberbox.Value = ""
End Sub
Private Sub pricebox_Change()
Me.Caption = Pricebox.Value
End Sub
Private Sub UserForm1_Initialize()
Namebox.Value = ""
Numberbox.Value = ""
Pricebox = ""
Buy.Value = True
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub CommandButton1_Click()
Range("a1").Value = CommandButton1.TopLeftCell.Address
UserForm1.Show
End Sub
Private Sub CommandButton2_Click()
Range("a1").Value = CommandButton2.TopLeftCell.Address
UserForm1.Show
End Sub
...
Private Sub OK_Click()
With Range(Range("a1").Value).Offset(10, 3).End(xlUp).Offset(1, 0)
.Offset(0, 0).Value = Namebox.Value
If Buy.Value Then
.Offset(0, 1).Value = "ซื้อ"
Else
.Offset(0, 1).Value = "ขาย"
End If
.Offset(0, 2).Value = Pricebox.Value
.Offset(0, 3).Value = Numberbox.Value
End With
Namebox.Value = ""
Pricebox.Value = ""
Numberbox.Value = ""
End Sub