Code below do great job printing my target area, but it also delete, clear active cell after I running this macro.
any idea why, help me modifying it.
thx
any idea why, help me modifying it.
thx
Code:
Sub Print_Myproblem()
Application.EnableEvents = False
Dim myRange As Range
Set myRange = Selection
Dim S As Shape
On Error GoTo 1
myRange = ActiveSheet.Range("A1:AG107")
ActiveSheet.PageSetup.PrintArea = myRange
For Each S In ActiveSheet.Shapes
S.ControlFormat.PrintObject = False
Next S
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
1: Exit Sub
Application.EnableEvents = True
End Sub