+ Reply to Thread
Results 1 to 8 of 8

Print selected cell in 1 sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    02-10-2012
    Location
    Selangor, Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Print selected cell in 1 sheet

    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.

    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!

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Print selected cell in 1 sheet

    If you want print selected cells what is the meaning of this line ?
    Range("A8:A60,B8:B60,C8:C60,D8:D60,E8:E60,F8:F60,G8:G60,H8:H60,I8:I60,K8:K60").Select
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    02-10-2012
    Location
    Selangor, Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Print selected cell in 1 sheet

    Quote Originally Posted by patel45 View Post
    If you want print selected cells what is the meaning of this line ?
    Range("A8:A60,B8:B60,C8:C60,D8:D60,E8:E60,F8:F60,G8:G60,H8:H60,I8:I60,K8:K60").Select
    It's mean I want to print for the cell A, B, C, D, E, F, G, H, I and K (from row 8 to 60). I got data in cell J but don't want to print that area.

    Btw, thanks for your reply.

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Print selected cell in 1 sheet

    on titlle you say print selected, then I understand
    1- select cells
    2- run macro to print selected

  5. #5
    Registered User
    Join Date
    02-10-2012
    Location
    Selangor, Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Print selected cell in 1 sheet

    Apologize for the title make you misunderstanding. Its correct for your previous understanding. I want select certain cell and run macro to print selected cell.

    But, it appear one cell on the page in the print preview. I'm still don't know what are the problem with that code.

  6. #6
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Print selected cell in 1 sheet

    attach a sample file for testing

  7. #7
    Registered User
    Join Date
    02-10-2012
    Location
    Selangor, Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Print selected cell in 1 sheet

    Apologize for late reply. Attached sample work book I created.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Print selected cell in 1 sheet

    We are loosing time, you attached file without macro and with only one range

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1