ในที่นี้ผมมีไฟล์งานลักษณะงานเหมือนกันหมายหลายสิบชีต
ต้องการแก้ไขงานครั้งเดียวทุกชีตต้องเขียน VBA อย่างไรครับ
ตอนนี้ที่ใช้ ผมใช้ Workbook_SheetActivate
แต่ปัญหาคือต้องกดชีตก่อน VBA จึงจะทำงานได้ครับ
Code: Select all
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ActiveSheet.Unprotect
Range("Z3").Select
Columns("S:Y").Select
Selection.Delete Shift:=xlToLeft
Range("G1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveWindow.SmallScroll Down:=-24
Range("T1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("O1").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
ActiveWindow.SmallScroll Down:=-27
Range("U1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("T1").Select
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 90
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("U1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 90
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("T:Y").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("V2").Select
End Sub
อยากได้แบบเปิด Excel มาแล้วจัดการเงื่อนไขที่เราต้องการจบในม้วนเดียวครับ คือจัดการทุกชีตเลย
ต้องปรับ code แบบไหนครับ