snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Sub Pasteformula()
Dim formBook As Workbook
Dim i As Integer
Dim rs As Range
Dim rt As Range
Set formBook = ThisWorkbook
With formBook.Sheets("Form")
i = .Range("Y203").Value
Set rs = .Range("R204:X204").Resize(i)
Set rt = .Range("G204")
rs.Copy: rt.PasteSpecial Paste:=xlPasteFormulas
End With
Call Protect
End Sub
Sub Protect()
With Sheets("Form")
If .ProtectContents = True Then .Unprotect Else .Protect
ActiveSheet.EnableSelection = xlUnlockedCells
End With
End Sub
Sub Protect()
With Sheets("Form")
If .ProtectContents = True Then .Unprotect Else .Protect
ActiveSheet.EnableSelection = xlUnlockedCells
End With
End Sub
Sub Pasteformula()
Dim formBook As Workbook
Dim i As Integer
Dim rs As Range
Dim rt As Range
Set formBook = ThisWorkbook
With formBook.Sheets("Form")
i = .Range("Y203").Value
Set rs = .Range("R204:X204").Resize(i)
Set rt = .Range("G204")
rs.Copy: rt.PasteSpecial Paste:=xlPasteFormulas
End With
Call Protect
End Sub
You do not have the required permissions to view the files attached to this post.
Sub Protect()
'โค๊ดนี้ใช้ป้องกันและยกเลิกการป้องกันชีทในฟอร์มบันทึกชื่อปุ่มกดเพื่อแก้ไข เลิก // ป้องกัน
With Sheets("Form")
If .ProtectContents = True Then
.Unprotect
Else
Call Pasteformula
.Protect
End If
ActiveSheet.EnableSelection = xlUnlockedCells
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$M$1" Then
With ActiveSheet.Calendar1
.Visible = True
.Top = ActiveCell.Offset(0, 0).Top
.Left = ActiveCell.Offset(0, 1).Left
.Width = 110 ' <= ปรับความกว้างปฎิทิน
.Height = 110 ' <= ปรับความสูงปฎิทิน
End With
Else
ActiveSheet.Calendar1.Visible = False
Application.OnKey "{F10}", "MainCode" ' กำหนดให้ " บันทึกข้อมูล "โดยกดแป้นคีย์บอร์ดตามในวงเล็บปีกกา"{?*}
Application.OnKey "{END}", "PoFormClose" ' กำหนดให้ " ปิดฟอร์ม"
End If
If Not Intersect(Target, Range("D204:D219")) Is Nothing Then
Application.SendKeys "%{DOWN}"
End If
Application.EnableEvents = True
End Sub
Private Sub Calendar1_Click()
ActiveCell.Value = Calendar1.Value
End Sub
Sub Protect()
'โค๊ดนี้ใช้ป้องกันและยกเลิกการป้องกันชีทในฟอร์มบันทึกชื่อปุ่มกดเพื่อแก้ไข เลิก // ป้องกัน
Application.EnableEvents = False
With Sheets("Form")
If .ProtectContents = True Then
.Unprotect
Else
Call Pasteformula
.Protect
End If
ActiveSheet.EnableSelection = xlUnlockedCells
End With
Application.EnableEvents = True
End Sub