#1   Report Post  
welshlad
 
Posts: n/a
Default Macro Help In Excel


Every morning we have a file imported containing rows of data. There are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad
  #2   Report Post  
Roger Govier
 
Posts: n/a
Default Macro Help In Excel

Hi

Assuming there is always date in column A of your sheet, then within your macro

Dim Counter as Long
Counter = Range("A65536").End(xlUp).Row

For i = 1 counter
your routine .....

Change he reference from A to another column if there is no data in column A.


Regards

Roger Govier


welshlad wrote:
Every morning we have a file imported containing rows of data. There are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


  #4   Report Post  
welshlad
 
Posts: n/a
Default Macro Help In Excel


Thank you for your comments regarding a macro in excel registering how
many rows there are of data.
I took your advice but now this happens : - it registers how many rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad



--
welshlad
  #5   Report Post  
Don Guillett
 
Posts: n/a
Default Macro Help In Excel

still not quite sure what you want but try this. Why do you want to
highlight the row?
Change printpreview to printOUT to actually print

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad" wrote in message
...

Thank you for your comments regarding a macro in excel registering how
many rows there are of data.
I took your advice but now this happens : - it registers how many rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
ColorIndex = 15
Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad



--
welshlad





  #6   Report Post  
welshlad
 
Posts: n/a
Default Macro Help In Excel


Want I want is for the first row to be shaded, then printed. Then the
first row to be deshaded, then shade the second row and print etc. The
macro realised how many rows I had but the shade only occured in the
row which the cursor was in when the macro was started.

Don Guillett Wrote:
still not quite sure what you want but try this. Why do you want to
highlight the row?
Change printpreview to printOUT to actually print

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

Thank you for your comments regarding a macro in excel registering
how
many rows there are of data.
I took your advice but now this happens : - it registers how many
rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
ColorIndex = 15
Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in
col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad


--
welshlad



--
welshlad
  #7   Report Post  
Don Guillett
 
Posts: n/a
Default Macro Help In Excel

Did you try what i posted, as posted? If not col A, change.
Why did you put .. instead of . for the with statements?

--
Don Guillett
SalesAid Software

"welshlad" wrote in message
...

Want I want is for the first row to be shaded, then printed. Then the
first row to be deshaded, then shade the second row and print etc. The
macro realised how many rows I had but the shade only occured in the
row which the cursor was in when the macro was started.

Don Guillett Wrote:
still not quite sure what you want but try this. Why do you want to
highlight the row?
Change printpreview to printOUT to actually print

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

Thank you for your comments regarding a macro in excel registering
how
many rows there are of data.
I took your advice but now this happens : - it registers how many
rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
ColorIndex = 15
Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in
col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad


--
welshlad



--
welshlad



  #8   Report Post  
welshlad
 
Posts: n/a
Default Macro Help In Excel


This is my macro now. It recognises how many rows of data there are,
prints that amount, which I want. But I want the first row to be
selected, shaded and printed, then unshaded, then the same with the
second row etc. The cursor still doesn't move though when the macro is
ran. Why? It's really frustrating me now.

Please help, any advice would be grateful.


Sub importprint()

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
Selection.Interior.ColorIndex = 15
ActiveWindow.SelectedSheets.PrintPreview
Selection.Interior.ColorIndex = 0
End With
Next i
End Sub



Don Guillett Wrote:
Did you try what i posted, as posted? If not col A, change.
Why did you put .. instead of . for the with statements?

--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

Want I want is for the first row to be shaded, then printed. Then the
first row to be deshaded, then shade the second row and print etc.
The
macro realised how many rows I had but the shade only occured in the
row which the cursor was in when the macro was started.

Don Guillett Wrote:
still not quite sure what you want but try this. Why do you want to
highlight the row?
Change printpreview to printOUT to actually print

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Thank you for your comments regarding a macro in excel registering
how
many rows there are of data.
I took your advice but now this happens : - it registers how many
rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
ColorIndex = 15
Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print
it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in
col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad


--
welshlad


--
welshlad



--
welshlad
  #9   Report Post  
Don Guillett
 
Posts: n/a
Default Macro Help In Excel

Professionals tend to avoid selections wherever possible. Why do you want to
move the cursor to the row to printhiliteprintunhilite when just printing
each row should do nicely. I'm also not quite sure why you want to print
each row separately.???

This does what you want, WITHOUT selecting. Try it.

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad" wrote in message
...

This is my macro now. It recognises how many rows of data there are,
prints that amount, which I want. But I want the first row to be
selected, shaded and printed, then unshaded, then the same with the
second row etc. The cursor still doesn't move though when the macro is
ran. Why? It's really frustrating me now.

Please help, any advice would be grateful.


Sub importprint()

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
Selection.Interior.ColorIndex = 15
ActiveWindow.SelectedSheets.PrintPreview
Selection.Interior.ColorIndex = 0
End With
Next i
End Sub



Don Guillett Wrote:
Did you try what i posted, as posted? If not col A, change.
Why did you put .. instead of . for the with statements?

--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

Want I want is for the first row to be shaded, then printed. Then the
first row to be deshaded, then shade the second row and print etc.
The
macro realised how many rows I had but the shade only occured in the
row which the cursor was in when the macro was started.

Don Guillett Wrote:
still not quite sure what you want but try this. Why do you want to
highlight the row?
Change printpreview to printOUT to actually print

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Thank you for your comments regarding a macro in excel registering
how
many rows there are of data.
I took your advice but now this happens : - it registers how many
rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
ColorIndex = 15
Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print
it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in
col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad


--
welshlad


--
welshlad



--
welshlad



  #10   Report Post  
welshlad
 
Posts: n/a
Default Macro Help In Excel


I copied and pasted your macro but it's not doing anything differently.
Yes it is registering how many rows there are and print previewing that
many entries, but the highlighting is remaining on the same cell.

Every day we have a list of client details. We print out a copy of the
list to put in to every client file. The row corresponding to the file
we highlight and put it into the front of the file. Therefore, if we
have 20 rows, we want 20 copies of the list, but with the individual
row highlighted.

Just cannot figure out why the macro does not go through the list
highlighting, whereas it just highlights, dehighlights, and
rehighlights the cell which the cursor was in immediately before
running the macro.

Ready to throw the computer now! hee hee

Luke

Don Guillett Wrote:
Professionals tend to avoid selections wherever possible. Why do you
want to
move the cursor to the row to printhiliteprintunhilite when just
printing
each row should do nicely. I'm also not quite sure why you want to
print
each row separately.???

This does what you want, WITHOUT selecting. Try it.

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

This is my macro now. It recognises how many rows of data there are,
prints that amount, which I want. But I want the first row to be
selected, shaded and printed, then unshaded, then the same with the
second row etc. The cursor still doesn't move though when the macro
is
ran. Why? It's really frustrating me now.

Please help, any advice would be grateful.


Sub importprint()

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
Selection.Interior.ColorIndex = 15
ActiveWindow.SelectedSheets.PrintPreview
Selection.Interior.ColorIndex = 0
End With
Next i
End Sub



Don Guillett Wrote:
Did you try what i posted, as posted? If not col A, change.
Why did you put .. instead of . for the with statements?

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Want I want is for the first row to be shaded, then printed. Then
the
first row to be deshaded, then shade the second row and print etc.
The
macro realised how many rows I had but the shade only occured in the
row which the cursor was in when the macro was started.

Don Guillett Wrote:
still not quite sure what you want but try this. Why do you want to
highlight the row?
Change printpreview to printOUT to actually print

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Thank you for your comments regarding a macro in excel registering
how
many rows there are of data.
I took your advice but now this happens : - it registers how many
rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
ColorIndex = 15
Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print
it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in
col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad


--
welshlad


--
welshlad


--
welshlad



--
welshlad


  #11   Report Post  
Don Guillett
 
Posts: n/a
Default Macro Help In Excel

I'm confused.
Again, what the macro does is hilite the row and print the ROW. Do you want
it to print all 20 rows with only the appropriate row hilited? If so, this
prints a1:d & last row

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
Range(Cells(1, 1), Cells(lastrow, 4)).PrintPreview
'.PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad" wrote in message
...

I copied and pasted your macro but it's not doing anything differently.
Yes it is registering how many rows there are and print previewing that
many entries, but the highlighting is remaining on the same cell.

Every day we have a list of client details. We print out a copy of the
list to put in to every client file. The row corresponding to the file
we highlight and put it into the front of the file. Therefore, if we
have 20 rows, we want 20 copies of the list, but with the individual
row highlighted.

Just cannot figure out why the macro does not go through the list
highlighting, whereas it just highlights, dehighlights, and
rehighlights the cell which the cursor was in immediately before
running the macro.

Ready to throw the computer now! hee hee

Luke

Don Guillett Wrote:
Professionals tend to avoid selections wherever possible. Why do you
want to
move the cursor to the row to printhiliteprintunhilite when just
printing
each row should do nicely. I'm also not quite sure why you want to
print
each row separately.???

This does what you want, WITHOUT selecting. Try it.

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

This is my macro now. It recognises how many rows of data there are,
prints that amount, which I want. But I want the first row to be
selected, shaded and printed, then unshaded, then the same with the
second row etc. The cursor still doesn't move though when the macro
is
ran. Why? It's really frustrating me now.

Please help, any advice would be grateful.


Sub importprint()

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
Selection.Interior.ColorIndex = 15
ActiveWindow.SelectedSheets.PrintPreview
Selection.Interior.ColorIndex = 0
End With
Next i
End Sub



Don Guillett Wrote:
Did you try what i posted, as posted? If not col A, change.
Why did you put .. instead of . for the with statements?

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Want I want is for the first row to be shaded, then printed. Then
the
first row to be deshaded, then shade the second row and print etc.
The
macro realised how many rows I had but the shade only occured in the
row which the cursor was in when the macro was started.

Don Guillett Wrote:
still not quite sure what you want but try this. Why do you want to
highlight the row?
Change printpreview to printOUT to actually print

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Thank you for your comments regarding a macro in excel registering
how
many rows there are of data.
I took your advice but now this happens : - it registers how many
rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
ColorIndex = 15
Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print
it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in
col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad


--
welshlad


--
welshlad


--
welshlad



--
welshlad



  #12   Report Post  
welshlad
 
Posts: n/a
Default Macro Help In Excel


The way you worded it is exactly what I want to happen, but somehow its
not happening. I am literally copying and pasting your macro, but all
it is doing is hiliting and deliting the only cell that the cursor is
in before the macro is ran. Any idea why this is?

Don Guillett Wrote:
I'm confused.
Again, what the macro does is hilite the row and print the ROW. Do you
want
it to print all 20 rows with only the appropriate row hilited? If so,
this
prints a1:d & last row

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
Range(Cells(1, 1), Cells(lastrow, 4)).PrintPreview
'.PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

I copied and pasted your macro but it's not doing anything
differently.
Yes it is registering how many rows there are and print previewing
that
many entries, but the highlighting is remaining on the same cell.

Every day we have a list of client details. We print out a copy of
the
list to put in to every client file. The row corresponding to the
file
we highlight and put it into the front of the file. Therefore, if we
have 20 rows, we want 20 copies of the list, but with the individual
row highlighted.

Just cannot figure out why the macro does not go through the list
highlighting, whereas it just highlights, dehighlights, and
rehighlights the cell which the cursor was in immediately before
running the macro.

Ready to throw the computer now! hee hee

Luke

Don Guillett Wrote:
Professionals tend to avoid selections wherever possible. Why do you
want to
move the cursor to the row to printhiliteprintunhilite when just
printing
each row should do nicely. I'm also not quite sure why you want to
print
each row separately.???

This does what you want, WITHOUT selecting. Try it.

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

This is my macro now. It recognises how many rows of data there are,
prints that amount, which I want. But I want the first row to be
selected, shaded and printed, then unshaded, then the same with the
second row etc. The cursor still doesn't move though when the macro
is
ran. Why? It's really frustrating me now.

Please help, any advice would be grateful.


Sub importprint()

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
Selection.Interior.ColorIndex = 15
ActiveWindow.SelectedSheets.PrintPreview
Selection.Interior.ColorIndex = 0
End With
Next i
End Sub



Don Guillett Wrote:
Did you try what i posted, as posted? If not col A, change.
Why did you put .. instead of . for the with statements?

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Want I want is for the first row to be shaded, then printed. Then
the
first row to be deshaded, then shade the second row and print etc.
The
macro realised how many rows I had but the shade only occured in the
row which the cursor was in when the macro was started.

Don Guillett Wrote:
still not quite sure what you want but try this. Why do you want to
highlight the row?
Change printpreview to printOUT to actually print

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Thank you for your comments regarding a macro in excel registering
how
many rows there are of data.
I took your advice but now this happens : - it registers how many
rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
ColorIndex = 15
Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print
it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in
col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad


--
welshlad


--
welshlad


--
welshlad


--
welshlad



--
welshlad
  #13   Report Post  
Don Guillett
 
Posts: n/a
Default Macro Help In Excel

If you like you may send to my personal email a SMALL workbook along with
exactly what you are trying to do. This should NOT be rocket science.

--
Don Guillett
SalesAid Software

"welshlad" wrote in message
...

The way you worded it is exactly what I want to happen, but somehow its
not happening. I am literally copying and pasting your macro, but all
it is doing is hiliting and deliting the only cell that the cursor is
in before the macro is ran. Any idea why this is?

Don Guillett Wrote:
I'm confused.
Again, what the macro does is hilite the row and print the ROW. Do you
want
it to print all 20 rows with only the appropriate row hilited? If so,
this
prints a1:d & last row

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
Range(Cells(1, 1), Cells(lastrow, 4)).PrintPreview
'.PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

I copied and pasted your macro but it's not doing anything
differently.
Yes it is registering how many rows there are and print previewing
that
many entries, but the highlighting is remaining on the same cell.

Every day we have a list of client details. We print out a copy of
the
list to put in to every client file. The row corresponding to the
file
we highlight and put it into the front of the file. Therefore, if we
have 20 rows, we want 20 copies of the list, but with the individual
row highlighted.

Just cannot figure out why the macro does not go through the list
highlighting, whereas it just highlights, dehighlights, and
rehighlights the cell which the cursor was in immediately before
running the macro.

Ready to throw the computer now! hee hee

Luke

Don Guillett Wrote:
Professionals tend to avoid selections wherever possible. Why do you
want to
move the cursor to the row to printhiliteprintunhilite when just
printing
each row should do nicely. I'm also not quite sure why you want to
print
each row separately.???

This does what you want, WITHOUT selecting. Try it.

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

This is my macro now. It recognises how many rows of data there are,
prints that amount, which I want. But I want the first row to be
selected, shaded and printed, then unshaded, then the same with the
second row etc. The cursor still doesn't move though when the macro
is
ran. Why? It's really frustrating me now.

Please help, any advice would be grateful.


Sub importprint()

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
Selection.Interior.ColorIndex = 15
ActiveWindow.SelectedSheets.PrintPreview
Selection.Interior.ColorIndex = 0
End With
Next i
End Sub



Don Guillett Wrote:
Did you try what i posted, as posted? If not col A, change.
Why did you put .. instead of . for the with statements?

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Want I want is for the first row to be shaded, then printed. Then
the
first row to be deshaded, then shade the second row and print etc.
The
macro realised how many rows I had but the shade only occured in the
row which the cursor was in when the macro was started.

Don Guillett Wrote:
still not quite sure what you want but try this. Why do you want to
highlight the row?
Change printpreview to printOUT to actually print

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Thank you for your comments regarding a macro in excel registering
how
many rows there are of data.
I took your advice but now this happens : - it registers how many
rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
ColorIndex = 15
Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print
it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in
col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad


--
welshlad


--
welshlad


--
welshlad


--
welshlad



--
welshlad



  #14   Report Post  
welshlad
 
Posts: n/a
Default Macro Help In Excel


Sent e-mail to , attached is a small workbook with the
macro in. Hope you can help.

Luke

Don Guillett Wrote:
If you like you may send to my personal email a SMALL workbook along
with
exactly what you are trying to do. This should NOT be rocket science.

--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

The way you worded it is exactly what I want to happen, but somehow
its
not happening. I am literally copying and pasting your macro, but all
it is doing is hiliting and deliting the only cell that the cursor is
in before the macro is ran. Any idea why this is?

Don Guillett Wrote:
I'm confused.
Again, what the macro does is hilite the row and print the ROW. Do
you
want
it to print all 20 rows with only the appropriate row hilited? If
so,
this
prints a1:d & last row

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
Range(Cells(1, 1), Cells(lastrow, 4)).PrintPreview
'.PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

I copied and pasted your macro but it's not doing anything
differently.
Yes it is registering how many rows there are and print previewing
that
many entries, but the highlighting is remaining on the same cell.

Every day we have a list of client details. We print out a copy of
the
list to put in to every client file. The row corresponding to the
file
we highlight and put it into the front of the file. Therefore, if we
have 20 rows, we want 20 copies of the list, but with the individual
row highlighted.

Just cannot figure out why the macro does not go through the list
highlighting, whereas it just highlights, dehighlights, and
rehighlights the cell which the cursor was in immediately before
running the macro.

Ready to throw the computer now! hee hee

Luke

Don Guillett Wrote:
Professionals tend to avoid selections wherever possible. Why do you
want to
move the cursor to the row to printhiliteprintunhilite when just
printing
each row should do nicely. I'm also not quite sure why you want to
print
each row separately.???

This does what you want, WITHOUT selecting. Try it.

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

This is my macro now. It recognises how many rows of data there are,
prints that amount, which I want. But I want the first row to be
selected, shaded and printed, then unshaded, then the same with the
second row etc. The cursor still doesn't move though when the macro
is
ran. Why? It's really frustrating me now.

Please help, any advice would be grateful.


Sub importprint()

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
Selection.Interior.ColorIndex = 15
ActiveWindow.SelectedSheets.PrintPreview
Selection.Interior.ColorIndex = 0
End With
Next i
End Sub



Don Guillett Wrote:
Did you try what i posted, as posted? If not col A, change.
Why did you put .. instead of . for the with statements?

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Want I want is for the first row to be shaded, then printed. Then
the
first row to be deshaded, then shade the second row and print etc.
The
macro realised how many rows I had but the shade only occured in the
row which the cursor was in when the macro was started.

Don Guillett Wrote:
still not quite sure what you want but try this. Why do you want to
highlight the row?
Change printpreview to printOUT to actually print

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Thank you for your comments regarding a macro in excel registering
how
many rows there are of data.
I took your advice but now this happens : - it registers how many
rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
ColorIndex = 15
Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print
it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in
col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad


--
welshlad


--
welshlad


--
welshlad


--
welshlad


--
welshlad



--
welshlad
  #15   Report Post  
Don Guillett
 
Posts: n/a
Default Macro Help In Excel

I got your workbook with the macro you provided which is NOT what I told you
to use. Use THIS to hilite each row and print the entire selection each time
with the next row hilited.

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
Range(Cells(1, 1), Cells(lastrow, 4)).PrintPreview
'.PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub
=======
you used this which is NOT what I sent.

Sub importprint1()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
Selection.Interior.ColorIndex = 15
Range(Cells(1, 1), Cells(lastrow, 4)).PrintPreview
ActiveWindow.SelectedSheets.PrintPreview
Selection.Interior.ColorIndex = 0
End With
Next i
End Sub



--
Don Guillett
SalesAid Software

"welshlad" wrote in message
...

Sent e-mail to
, attached is a small workbook with the
macro in. Hope you can help.

Luke

Don Guillett Wrote:
If you like you may send to my personal email a SMALL workbook along
with
exactly what you are trying to do. This should NOT be rocket science.

--
Don Guillett
SalesAid Software

"welshlad"
wrote in message
...

The way you worded it is exactly what I want to happen, but somehow
its
not happening. I am literally copying and pasting your macro, but all
it is doing is hiliting and deliting the only cell that the cursor is
in before the macro is ran. Any idea why this is?

Don Guillett Wrote:
I'm confused.
Again, what the macro does is hilite the row and print the ROW. Do
you
want
it to print all 20 rows with only the appropriate row hilited? If
so,
this
prints a1:d & last row

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
Range(Cells(1, 1), Cells(lastrow, 4)).PrintPreview
'.PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

I copied and pasted your macro but it's not doing anything
differently.
Yes it is registering how many rows there are and print previewing
that
many entries, but the highlighting is remaining on the same cell.

Every day we have a list of client details. We print out a copy of
the
list to put in to every client file. The row corresponding to the
file
we highlight and put it into the front of the file. Therefore, if we
have 20 rows, we want 20 copies of the list, but with the individual
row highlighted.

Just cannot figure out why the macro does not go through the list
highlighting, whereas it just highlights, dehighlights, and
rehighlights the cell which the cursor was in immediately before
running the macro.

Ready to throw the computer now! hee hee

Luke

Don Guillett Wrote:
Professionals tend to avoid selections wherever possible. Why do you
want to
move the cursor to the row to printhiliteprintunhilite when just
printing
each row should do nicely. I'm also not quite sure why you want to
print
each row separately.???

This does what you want, WITHOUT selecting. Try it.

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

This is my macro now. It recognises how many rows of data there are,
prints that amount, which I want. But I want the first row to be
selected, shaded and printed, then unshaded, then the same with the
second row etc. The cursor still doesn't move though when the macro
is
ran. Why? It's really frustrating me now.

Please help, any advice would be grateful.


Sub importprint()

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
Selection.Interior.ColorIndex = 15
ActiveWindow.SelectedSheets.PrintPreview
Selection.Interior.ColorIndex = 0
End With
Next i
End Sub



Don Guillett Wrote:
Did you try what i posted, as posted? If not col A, change.
Why did you put .. instead of . for the with statements?

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Want I want is for the first row to be shaded, then printed. Then
the
first row to be deshaded, then shade the second row and print etc.
The
macro realised how many rows I had but the shade only occured in the
row which the cursor was in when the macro was started.

Don Guillett Wrote:
still not quite sure what you want but try this. Why do you want to
highlight the row?
Change printpreview to printOUT to actually print

Sub importprint()
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow
With Rows(i)
..Interior.ColorIndex = 15
..PrintPreview
..Interior.ColorIndex = 0
End With
Next i
End Sub

--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Thank you for your comments regarding a macro in excel registering
how
many rows there are of data.
I took your advice but now this happens : - it registers how many
rows
of data there are, but the shading does not move down.

Here's my macro : -

Sub importprint()
'
' importprint Macro
' Macro recorded 14/10/2005 by WP122
'

'
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lastrow

With Selection.Interior
ColorIndex = 15
Pattern = xlSolid
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Selection.Interior.ColorIndex = xlNone

Next i
End Sub


(I want the macro to highlight the first row, highlight it, print
it,
then de-highlight it, then move on to the second row and do the same
process etc etc.

Can you help at all?

Regards,

Luke

Don Guillett Wrote:
As always, post your code for comments but to find the last row in
col
A

lastrow=cells(rows.count,"a").end(xlup).row
for i=2 to lastrow
your stuff
next i
--
Don Guillett
SalesAid Software

"welshlad"
wrote in
message
...

Every morning we have a file imported containing rows of data. There
are
a different amount of entries every day. I have managed to set up a
macro that goes through each row individually highlighting it and
printing it off. Therefore, if I have an import with 20 rows, my
macro
prints off 20 copies, with each row individually being highlighted.

My problem is that I can only do this if I firstly enter into the
macro
how many rows of data there are. Is there any way the macro can work
through the rows, and know when to stop?

Any advice will be gratefully received.


--
welshlad


--
welshlad


--
welshlad


--
welshlad


--
welshlad


--
welshlad



--
welshlad



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
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
passing arguments from an excel macro to a word macro KWE39 Excel Discussion (Misc queries) 1 July 7th 05 03:56 PM
Excel macro that opens new MS Word file and pastes data as a pictu Rob Excel Worksheet Functions 0 July 6th 05 05:12 PM
Can't find macro in an Excel file to delete it Ron Excel Discussion (Misc queries) 3 July 1st 05 01:07 PM
Saving Excel using Macro mrbalaje Excel Discussion (Misc queries) 4 April 20th 05 02:32 PM


All times are GMT +1. The time now is 11:07 AM.

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"