+ Reply to Thread
Results 1 to 4 of 4

setting print area

Hybrid View

  1. #1
    Nick Smith
    Guest

    setting print area

    Hi,

    Can anyone help me with a macro to search down column A from row 15 onwards
    (inclusive) until it finds the last cell containing any text (cell #), and
    then set the print area to cells A1:X#, where # is the last cell in column A
    containing any text?

    Any help with this would be much appreciated!

    Thanks in advance,

    Nick

  2. #2
    Norman Jones
    Guest

    Re: setting print area

    Hi Nick,

    Try:

    '=============>>
    Public Sub Tester()
    Dim SH As Worksheet
    Dim rng As Range
    Dim LRow As Long

    Set SH = ActiveSheet '<<==== CHANGE

    With SH
    LRow = SH.Cells(Rows.Count, "A").End(xlUp).Row
    Set rng = .Range("A15:A" & LRow)
    .PageSetup.PrintArea = rng.Address
    End With

    End Sub
    '<<=============


    ---
    Regards,
    Norman


    "Nick Smith" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > Can anyone help me with a macro to search down column A from row 15
    > onwards
    > (inclusive) until it finds the last cell containing any text (cell #), and
    > then set the print area to cells A1:X#, where # is the last cell in column
    > A
    > containing any text?
    >
    > Any help with this would be much appreciated!
    >
    > Thanks in advance,
    >
    > Nick




  3. #3
    Norman Jones
    Guest

    Re: setting print area

    Hi Nick,

    Change:

    > Set rng = .Range("A15:A" & LRow)


    to

    Set rng = .Range("A15:X" & LRow)

    where X is the last column to be printed.


    ---
    Regards,
    Norman





  4. #4
    Nick Smith
    Guest

    Re: setting print area

    Another thank you. Works a treat.

    "Norman Jones" wrote:

    > Hi Nick,
    >
    > Try:
    >
    > '=============>>
    > Public Sub Tester()
    > Dim SH As Worksheet
    > Dim rng As Range
    > Dim LRow As Long
    >
    > Set SH = ActiveSheet '<<==== CHANGE
    >
    > With SH
    > LRow = SH.Cells(Rows.Count, "A").End(xlUp).Row
    > Set rng = .Range("A15:A" & LRow)
    > .PageSetup.PrintArea = rng.Address
    > End With
    >
    > End Sub
    > '<<=============
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "Nick Smith" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > >
    > > Can anyone help me with a macro to search down column A from row 15
    > > onwards
    > > (inclusive) until it finds the last cell containing any text (cell #), and
    > > then set the print area to cells A1:X#, where # is the last cell in column
    > > A
    > > containing any text?
    > >
    > > Any help with this would be much appreciated!
    > >
    > > Thanks in advance,
    > >
    > > Nick

    >
    >
    >


+ 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