VBA บันทึกข้อมูลเมื่อกดปุ่ม Button
Posted: Thu Jun 09, 2016 3:12 pm
สวัสดีครับ หากผมต้องการแทรกฟังก์ชั่นบันทึกข้อมูลเมื่อกดปุ่ม Button จะแทรกตรงไหนครับ
ขอบคุณครับ
Code: Select all
Sub record()
Dim i&
With ActiveSheet
.Unprotect Password:="3890" '<==UnProtect
If .Range("E6") <> "" And .Range("I6") <> "" _
And .Range("E8") <> "" And .Range("N10") <> "" _
And .Range("F12") <> "" And .Range("N12") <> "" _
And .Range("F14") <> "" And .Range("L14") <> "" _
And .Range("E18") <> "" Then
i = .Range("A" & .Rows.Count).End(xlUp).Offset(1, 0).Row
.Range("a" & i).Value = .Range("a21").Value
.Range("b" & i).Value = .Range("b21").Value
.Range("d" & i).Value = .Range("d21").Value
.Range("e" & i).Value = .Range("e21").Value
.Range("k" & i).Value = .Range("k21").Value
.Range("p" & i).Value = .Range("p21").Value
.Range("t" & i).Value = .Range("t21").Value
.Range("w" & i).Value = .Range("w21").Value
.Range("z" & i).Value = .Range("z21").Value
.Range("ac" & i).Value = .Range("ac21").Value
.Range("e6,I6,E8,N10,F12,N12,F14,L14,E18") _
.SpecialCells(xlCellTypeConstants).ClearContents
MsgBox ("ºÑ¹·Ö¡¢éÍÁÙÅàÃÕºÃéÍÂ")
Else
MsgBox ("¤Ø³ÂѧãÊè¢éÍÁÙÅäÁè¤Ãº")
.Range("R4").Select
End If