Macro to print an area in Excel and edit a cell approximately 500 times

Msinmath

New Member
Joined
Oct 31, 2020
Messages
5
Office Version
  1. 2013
Platform
  1. Windows
I'm a macro novice and I need some help. I have a sheet called results and a print area called results analysis. Within the sheet commencing at cell J7 there is a list of around 500 names. Cell B3 within the print area should contain the name from J7. Once it has printed, B3 should contain J8 and start the print cycle again. This should continue until it reaches a cell which contains 0,0. I need a macro which can do this automatically. Without a macro, this is a laborious task. Can anyone please help?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Please post a copy of your workbook.

This forum does not provide a means to do so. You will need to post it to a CLOUD Download website and provide the download link here.
 
Upvote 0
Please post a copy of your workbook.

This forum does not provide a means to do so. You will need to post it to a CLOUD Download website and provide the download link here.
Hi Logit

Thank you for offering to take a look at my problem. I have created a smaller version of the spreadsheet for you to peruse.
Here is the link
 
Upvote 0
Your example workbook does not match the description in your original post.
 
Upvote 0
VBA Code:
Sub Msinmath_Printing()
'https://www.mrexcel.com/board/threads/macro-to-print-an-area-in-excel-and-edit-a-cell-approximately-500-times.1149934/
Dim i As Long, Sh As Worksheet
Dim LRow As Long

Application.ScreenUpdating = False

Set Sh = Sheets("Results")
LRow = Sh.Cells(Rows.Count, "J").End(xlUp).Row

For i = 7 To LRow
    If Not Sh.Cells(i, 10) = "0,0" Then
        Sh.Cells(3, 2) = Sh.Cells(i, 10)
            Sh.PrintOut
    Else
        MsgBox "Printing has completed", vbOKOnly + vbInformation, "Macro complete"
    End If
Next i

Application.ScreenUpdating = True

End Sub
 
Upvote 0
Your example workbook does not match the description in your original post.
Apologies for the discrepancies as I had edited the file before sending it to you. Cell B3 is now A7 and J7 is now J9.
 
Upvote 0
Amended to suit your new ranges

VBA Code:
Sub Msinmath_Printing2()
'https://www.mrexcel.com/board/threads/macro-to-print-an-area-in-excel-and-edit-a-cell-approximately-500-times.1149934/
Dim i As Long, Sh As Worksheet
Dim LRow As Long

Application.ScreenUpdating = False

Set Sh = Sheets("Results")
LRow = Sh.Cells(Rows.Count, "J").End(xlUp).Row

For i = 9 To LRow
    If Not Sh.Cells(i, 10) = "0,0" Then
        Sh.Cells(7, 1) = Sh.Cells(i, 10)
            Sh.PrintOut
    Else
        MsgBox "Printing has completed", vbOKOnly + vbInformation, "Macro complete"
    End If
Next i

Application.ScreenUpdating = True

End Sub
 
Upvote 0
VBA Code:
Sub Msinmath_Printing()
'https://www.mrexcel.com/board/threads/macro-to-print-an-area-in-excel-and-edit-a-cell-approximately-500-times.1149934/
Dim i As Long, Sh As Worksheet
Dim LRow As Long

Application.ScreenUpdating = False

Set Sh = Sheets("Results")
LRow = Sh.Cells(Rows.Count, "J").End(xlUp).Row

For i = 7 To LRow
    If Not Sh.Cells(i, 10) = "0,0" Then
        Sh.Cells(3, 2) = Sh.Cells(i, 10)
            Sh.PrintOut
    Else
        MsgBox "Printing has completed", vbOKOnly + vbInformation, "Macro complete"
    End If
Next i

Application.ScreenUpdating = True

End Sub
Thank you. I'll try this out and see it works.
 
Upvote 0
make sure you use the one that suits where ever you have decided your ranges are
 
Upvote 0
make sure you use the one that suits where ever you have decided your ranges are
Hi Cooper645

Thank you for the macro. It prints but does not stop when it reaches a cell with a value of zero. Can the macro be amended to do this? I do not want to decimate a rainforest by using too much paper.
Thank you
 
Upvote 0

Forum statistics

Threads
1,214,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top