Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50090

Print selected cell in 1 sheet

$
0
0
Hi guys,

Need help here.

I try to print certain data with selected cell. It works to preview the print. However, it showed cell by cell and the user need to click next page to view another cell. Here is the code I try to do.

Code:

Public Sub Print1_click()

 Dim Rng1 As Range
    Set Rng1 = Range("K10:K10")


'.oWS = ActiveCell.Range("$L$10:$L$10")
'Application.Dialogs(xlDialogPrint).Show

On Error Resume Next
    With Application
        .DisplayFullScreen = False
        .CommandBars("Worksheet Menu Bar").Enabled = True
    End With
'ActiveSheet.Range("$A$10:$L$500").AutoFilter Field:=12

If Rng1.FilterMode.Columns = True Then

    Range("K10").Select
    ActiveSheet.Range("$A$10:$L$500").AutoFilter Field:=12, Criteria1:="<>"

    Range("A8:A60,B8:B60,C8:C60,D8:D60,E8:E60,F8:F60,G8:G60,H8:H60,I8:I60,K8:K60").Select
    Range("A8:A60,B8:B60,C8:C60,D8:D60,E8:E60,F8:F60,G8:G60,H8:H60,I8:I60,K8:K60").Activate
'    ActiveWindow.SmallScroll Down:=-126
    Selection.PrintOut Copies:=1, From:=1, To:=32766, Copies:=1, Preview:=True
 

ElseIf Rng1.FilterMode.Columns = False Then
   
    Range("K10").Select
    ActiveSheet.Range("$A$10:$L$500").AutoFilter Field:=13, Criteria1:="<>"
    Range("A8:I60").Select
    Selection.PrintOut From:=1, To:=32766, Copies:=1, Preview:=True
   
End If
End Sub

Print preview image showed here:

print 1.jpg

print 2.jpg

Thanks!

Viewing all articles
Browse latest Browse all 50090

Trending Articles