Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default Create a Macro to Print pages which contain content

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.

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 cells and if there is data, then the page would be printed. I'm just not sure how to go forward. Any assistance would be apprecieted. Let me know if more information is needed.
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 3,872
Default Create a Macro to Print pages which contain content

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
  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 3,872
Default Create a Macro to Print pages which contain content

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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Query SharePoint Site for Existing Pages Content Type girlgeek101 Excel Programming 1 October 19th 09 11:13 PM
need a print macro to print only a certain number of pages Tonso Excel Discussion (Misc queries) 2 July 26th 06 06:03 PM
macro to print only pages that are filled in Tonso Excel Discussion (Misc queries) 0 July 6th 06 05:32 PM
macro to print the first two pages of every tab in excel? Felipe Excel Programming 1 March 30th 06 02:02 PM
Macro to Select Pages & Show Print Ad Excel Programming 1 July 22nd 03 11:44 AM


All times are GMT +1. The time now is 11:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"