+ Reply to Thread
Results 1 to 11 of 11

Set Print Area

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    242

    Set Print Area

    I am using code to select a Print Area and it keeps only selection one cell and giving me an error. Here is the code:

    Cells.Find(What:="TX", After:=Cells(finalrow, 1), LookIn:=xlValues, LookAt:= _
            xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=True).Offset(0, 18).Select
        
        Range("A2", ActiveCell).Select
            
        ActiveSheet.PageSetup.PrintArea = Selection
    I have tried many other ways and they all keep giving me the same problem. Thank you all for the help in advance.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Set Print Area

    What are you trying to set the print area to?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    242

    Re: Set Print Area

    from range A2 to the cell that it finds in the find command. It will always be a different spot so I have to make it dynamic like I did.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Set Print Area

    Try this:
        Dim r As Range
        
        Set r = Cells.Find(What:="TX", _
                   After:=Cells(Rows.Count, "A"), _
                   LookIn:=xlValues, _
                   LookAt:=xlPart, _
                   SearchOrder:=xlByColumns, _
                   SearchDirection:=xlPrevious, _
                   MatchCase:=True)
        If r Is Nothing Then
            MsgBox "Not found"
        Else
            ActiveSheet.PageSetup.PrintArea = Range("A2", r.Offset(, 18)).Address
        End If

  5. #5
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    242

    Re: Set Print Area

    Thank you that worked perfectly.

    How do you know a way to set the amount of copies? I want the print dialog to open with 12 copies already filled in?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Set Print Area

    Try recording a macro, and we'll help you clean it up.

  7. #7
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    242

    Re: Set Print Area

    I just did record a macro and this is what comes out:

    ActiveWindow.SelectedSheets.PrintOut Copies:=12
    That is not what I want because it does not bring up the print dialog box. I want to set the copies to 12 but bring up the print dialog box. Is this possible?

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Set Print Area

    Application.Dialogs(xlDialogPrint).Show

  9. #9
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    242

    Re: Set Print Area

    I already have that code. The issue is I want it to open with 12 copies already set. Is that possible?

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Set Print Area

    Don't think so.

  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,378

    Re: Set Print Area

    Maybe you should do a .printpreview and change it to 12 by hand and then have it print.

+ 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