Option Explicit
Sub GPE()
Dim Item, Sh As Worksheet, Wb As Workbook
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Filters.Add "Excel File", "*.xls*", 1
If Not .Show = -1 Then
MsgBox "Ban chua chon File", vbInformation, "Thông báo"
Exit Sub
End If
'On Error Resume Next
For Each Item In .SelectedItems
Set Wb = Workbooks.Open(Item)
Wb.Activate
With Wb
Set Sh = .Sheets(1)
FormatCell Sh
.Save
.Close
Set Sh = Nothing
End With
Next Item
Set Wb = Nothing
MsgBox "Da thuc hien xong", vbExclamation, "---GPE---"
End With
End Sub
Sub FormatCell(Sh As Worksheet)
With Sh
.Range("K4:K17").Copy
.Range("L4:L17").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
.Columns("L:L").ColumnWidth = 28.14
.Range("L5:L17").HorizontalAlignment = xlLeft
.Range("L4").Value2 = "Ghi chú"
With .Range("L4").Font
.Color = -16776961
.TintAndShade = 0
End With
.Range("L5").FormulaR1C1 = "=R3C8"
.Range("L5").AutoFill Destination:=.Range("L5:L17"), Type:=xlFillDefault
With .Range("L5:L17").Font
.Color = -16727809
.TintAndShade = 0
.Bold = True
End With
.Columns("C:C").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
.Columns("C:C").ColumnWidth = 13.14
.Range("C4").Value2 = "S" & ChrW(7889) & " lô"
.Range("C5").FormulaR1C1 = "=R1C9"
.Range("C5").AutoFill Destination:=.Range("C5:C17"), Type:=xlFillDefault
With .Range("C5:C17").Font
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0
End With
With .Range("C4").Font
.Color = -16776961
.TintAndShade = 0
End With
End With
End Sub