Không hiểu cái:Tôi có file đính kèm muốn nhờ các bạn tìm nguyên nhân gây lỗi out of memory để hoàn thiện code giúp tôi với. thanks.
Sub Test()
Dim Rng As Range, i As Long
For i = 1 To 12
[m1] = i
If [a3] = True Then
Columns("F:K").EntireColumn.Hidden = False
With ActiveSheet.PageSetup
.Orientation = xlLandscape
End With
End If
ActiveWindow.SelectedSheets.PrintOut From:=1, to:=1, Copies:=1, collate:=True
Columns("F:K").EntireColumn.Hidden = True
With ActiveSheet.PageSetup
.Orientation = xlPortrait
End With
Next
End Sub
Xin lỗi bạn, tôi mù tịt về VBA, tôi muốn diễn tả M1 thay đổi giá trị sau mỗi lần in theo thứ tự từ 1 đến 12 nhưng tôi không biết cú pháp như thế nào. Để tôi thử lại code của bạn xem thế nào nhé. Thanks.Không hiểu cái:
Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) As Range
là cái gì nữa (vì chưa thấy bao giờ)
Bạn thử sửa lại thành:
PHP:Sub Test() Dim Rng As Range, i As Long For i = 1 To 12 [m1] = i If [a3] = True Then Columns("F:K").EntireColumn.Hidden = False With ActiveSheet.PageSetup .Orientation = xlLandscape End With End If ActiveWindow.SelectedSheets.PrintOut From:=1, to:=1, Copies:=1, collate:=True Columns("F:K").EntireColumn.Hidden = True With ActiveSheet.PageSetup .Orientation = xlPortrait End With Next End Sub