snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Sub Record()
Dim rs As Range, rt As Range, rc As Range
With Worksheets("br_code")
Set rs = .Range("A2:B2")
Set rt = .Range("A65536").End(xlUp).Offset(1, 0)
Set rc = .Range("F2")
End With
If rc = True Then
MsgBox "This Branch already exist."
Exit Sub
Else
rs.Copy: rt.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End If
MsgBox "Finish"
End Sub
Sub EditRec()
Dim rs As Range, rt As Range
Dim rc As Range, rd As Range
Dim re As Range
With Worksheets("br_code")
Set rs = .Range("A2:B2")
Set rt = .Range("A65536").End(xlUp).Offset(1, 0)
Set rc = .Range("F2")
Set rd = .Range("F3")
Set re = .Range("A4").Offset(rd.Value, 0)
End With
If rc = True Then
rs.Copy: re.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Else
MsgBox "This record has not exist."
Exit Sub
End If
MsgBox "Finish"
End Sub
Sub FindData()
Dim re As Range, rd As Range, rc As Range
With Worksheets("br_code")
Set rc = .Range("F2")
Set rd = .Range("F3")
Set re = .Range("A4").Offset(rd.Value, 0)
End With
If rc = False Then
MsgBox "No record were found"
Exit Sub
Else
re.Select
End If
End Sub
Sub DelRecord()
Dim re As Range, rd As Range, rc As Range
With Worksheets("br_code")
Set rc = .Range("F2")
Set rd = .Range("F3")
Set re = .Range("A4").Offset(rd.Value, 0)
End With
If rc = False Then
MsgBox "No record were found"
Exit Sub
Else
re.EntireRow.Delete
End If
MsgBox "Delete Finish"
End Sub
You do not have the required permissions to view the files attached to this post.