macro only prints out first and last line of document

G

Guest

I can't get a reply to incrementing dates so I manually wrote a macro that
would start with Jan 1 2004 then print, go to the next line of code Jan 2
2004 then print. I tried to add lines in between for dates Jan 3, Jan 4,
etc. What is printing out is the first select and the last select. What is
wrong with it. *I ' the lines out to see the code run but does not print out
with the 'references removed

Range("I1:J1").Select
ActiveCell.FormulaR1C1 = "1/1/2004"
Range("I2").Select
Application.Goto Reference:="Print_Area"
Selection.PrintOut Copies:=1, Collate:=True
Range("I1:J1").Select
ActiveCell.FormulaR1C1 = "1/2/2004"
Range("I2").Select
Application.Goto Reference:="Print_Area"
Range("I1:J1").Select
ActiveCell.FormulaR1C1 = "1/3/2004"
Range("I2").Select
Application.Goto Reference:="Print_Area"
'Range("I1:J1").Select
'ActiveCell.FormulaR1C1 = "1/4/2004"
'Range("I2").Select
'Application.Goto Reference:="Print_Area"
'Range("I1:J1").Select
'ActiveCell.FormulaR1C1 = "1/5/2004"
'Range("I2").Select
Application.Goto Reference:="Print_Area"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
 
R

Ron de Bruin

Do you mean this ?

If you fill in 3 it will print the sheet three times with another date
Delete "preview:=True" if it is working corect



Sub PrintCopies_ActiveSheet()
Dim CopiesCount As Long
Dim CopieNumber As Long

Range("I1").Value = "1/1/2004"

CopiesCount = Application.InputBox("How many Copies do you want", Type:=1)

For CopieNumber = 1 To CopiesCount
ActiveSheet.PrintOut preview:=True
Range("I1").Value = Range("I1").Value + 1
Next CopieNumber

End Sub
 
G

Guest

you need the following line
Selection.PrintOut Copies:=1, Collate:=True
after each
Application.Goto Reference:="Print_Area"
 
G

Guest

I figured that out by recording a macro (cheat) and inputting Jan 1, 04 - Jan
31, 04. When looking at the code of the macro i saw what the problem was.
Now I have a new problem. I have 31 dates for January 2004. They are
written as follows
ActiveCell.FormulaR1C1 = "1/1/2004"

I want to replace all the "1" with "2" to run the macro for the next month.
Where do I find the syntax to replace this or does it need another macro to
do it. Additionally I would have liked to have something like a start date
and an end date which would have performed the same actions with many fewer
lines. I did not know how to write that. I did see pieces of several codes
but did not know how to adapt my needs to it.
 
G

Guest

no I just need 1 copy printed from each day in the entire year. The
spreadsheet has been set up to insert a date into cell I1. This has to be
done for each day separately. Bummer. What I wanted originally was to do
this with some vba code or a macro that would either let me insert the start
date and the macro would run, print a page, then goto cell I1 and change the
date to the next day of the month and would run until it reached an ending
date. I cheated with a macro and like my answer to justahelper had to input
all 31 days manually. Now I don't know a way to replace the "1/1/2004" to
do the month of February, and so on. Any help is appreciated.
 
R

Ron de Bruin

Have you try the macro ?

If you enter 30 it will print 30 pages with in the first
1/1/2004 the seconf 1/2/2004.....
 
G

Guest

I need to replace January (1) with February (2)
To use another macro how would that work with what I already have?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top