snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Private Sub CommandButton4_Click()
Dim lastrow As Long
lastrow = Worksheets("custumer").Cells(Rows.Count, 2).End(xlUp).Row
For i = 2 To lastrow
If Worksheets("custumer").Cells(i, 4).Value = txtId.Text Then
Worksheets("custumer").Cells(i, 5).Value = txtcus1.Text
Worksheets("custumer").Cells(i, 6).Value = txtcus2.Text
End If
Next
With FrmCustumer
.txtId.Value = ""
.txtcus1.Value = ""
.txtcus2.Value = ""
End With
End Sub
You do not have the required permissions to view the files attached to this post.
Private Sub CommandButton4_Click()
Dim lastrow As Long
lastrow = Me.txtId.Value
With ThisWorkbook.Worksheets("custumer")
.Cells(lastrow + 1, "e").Value = Me.txtcus1.Value
.Cells(lastrow + 1, "f").Value = Me.txtcus2.Value
End With
'lastrow = Worksheets("custumer").Cells(Rows.Count, 2).End(xlUp).Row
' For i = 2 To lastrow
' If Worksheets("custumer").Cells(i, 4).Value = txtId.Text Then
' Worksheets("custumer").Cells(i, 5).Value = txtcus1.Text
' Worksheets("custumer").Cells(i, 6).Value = txtcus2.Text
' End If
' Next
With FrmCustumer
.txtId.Value = ""
.txtcus1.Value = ""
.txtcus2.Value = ""
End With
End Sub