Create a Macro to Print pages which contain content

Discussion in 'Excel Beginners' started by Nerodia, Oct 24, 2013.

  1. Nerodia

    Nerodia Guest

    I am new to writing macros and I need assistance with writing a macro t
    select the pages which contain data. I have a monetary inpu
    spreadsheet, which can range from 1 line of data to 500. I would lik
    to automate the print function to only select the pages which have dat
    to print.

    I am guessing that I will need to define a column, for example:

    Dim AccountNumber As String

    I will need to write an If, then statement to look for data in the cell
    and if there is data, then the page would be printed. I'm just not sur
    how to go forward. Any assistance would be apprecieted. Let me know i
    more information is needed


    --
    Nerodia
     
    Nerodia, Oct 24, 2013
    #1
    1. Advertisements

  2. Nerodia

    Claus Busch Guest

    Hi,

    Am Thu, 24 Oct 2013 17:54:42 +0100 schrieb Nerodia:

    > I am new to writing macros and I need assistance with writing a macro to
    > select the pages which contain data. I have a monetary input
    > spreadsheet, which can range from 1 line of data to 500. I would like
    > to automate the print function to only select the pages which have data
    > to print.


    try:
    Sub Test()
    Dim LRow As Long
    Dim LCol As Long

    With Sheets("Sheet1")
    LRow = .Cells(.Rows.Count, 1).End(xlUp).Row
    LCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    .PageSetup.PrintArea = _
    Range(Cells(1, 1), Cells(LRow, LCol)).Address
    .PrintOut Copies:=1
    End With
    End Sub


    Regards
    Claus B.
    --
    Win XP PRof SP2 / Vista Ultimate SP2
    Office 2003 SP2 /2007 Ultimate SP2
     
    Claus Busch, Oct 24, 2013
    #2
    1. Advertisements

  3. Nerodia

    Claus Busch Guest

    Hi again,

    Am Thu, 24 Oct 2013 20:22:59 +0200 schrieb Claus Busch:

    better try:

    Sub Test()
    Dim LRow As Long
    Dim LCol As Long

    With Sheets("Sheet1")
    LRow = .Cells(.Rows.Count, 1).End(xlUp).Row
    LCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    If LRow > 1 And LCol > 1 Then
    .PageSetup.PrintArea = _
    Range(Cells(1, 1), Cells(LRow, LCol)).Address
    .PrintOut Copies:=1
    End If
    End With
    End Sub


    Regards
    Claus B.
    --
    Win XP PRof SP2 / Vista Ultimate SP2
    Office 2003 SP2 /2007 Ultimate SP2
     
    Claus Busch, Oct 24, 2013
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cachod1

    Count cells in a column that contain dates

    Cachod1, Mar 29, 2005, in forum: Excel Beginners
    Replies:
    1
    Views:
    100
    Dave Peterson
    Mar 29, 2005
  2. ThirdTim
    Replies:
    1
    Views:
    72
    Guest
    May 5, 2005
  3. Grammurph7
    Replies:
    4
    Views:
    231
    Gord Dibben
    Dec 16, 2005
  4. blunoob
    Replies:
    1
    Views:
    78
    Norman Jones
    Dec 19, 2005
  5. John
    Replies:
    7
    Views:
    66
  6. Ed Cain

    counting cells that contain a specific value

    Ed Cain, Sep 4, 2006, in forum: Excel Beginners
    Replies:
    2
    Views:
    109
    Don Guillett
    Sep 4, 2006
  7. Gnugs
    Replies:
    1
    Views:
    113
    Stefi
    Mar 7, 2007
  8. Michael Slater

    Help with summing numbers in cells that also contain text

    Michael Slater, Aug 25, 2007, in forum: Excel Beginners
    Replies:
    6
    Views:
    108
    macropod
    Sep 1, 2007
Loading...