-
1 mã VBA dùng chung cho nhiều sheet tên khác nhau
Em dùng record macro để lọc dữ liệu, nhưng mà chỉ dùng được cho 1 sheet, do dữ liệu ở các sheet khác có cấu trúc giống nhau. Có đoạn mã nào để thay chỗ này ActiveWorkbook.Worksheets("PACKING") thành dùng chung cho nhiều sheet được không ạ?
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+Shift+Q
'
Range("A1
1").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("PACKING").AutoFilter.So rt.SortFields.Clear
ActiveWorkbook.Worksheets("PACKING").AutoFilter.So rt.SortFields.Add Key:= _
Range("D1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("PACKING").AutoFilter.So rt
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Selection.AutoFilter
Range("F12").Select
End Sub
Mong các cao thủ trợ giúp với![IMG]images/smilies/a41.gif[/IMG]
View more random threads:
-
thử thay ActiveWorkbook.Worksheets("PACKING") thành
ActiveSheet
bạn nhé
Quyền viết bài
- Bạn Không thể gửi Chủ đề mới
- Bạn Không thể Gửi trả lời
- Bạn Không thể Gửi file đính kèm
- Bạn Không thể Sửa bài viết của mình
-
Nội quy - Quy định