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?
 
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
Apologies, oversight on my part, have added the exit sub when you get down to a cell containing 0,0

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"
        Application.ScreenUpdating = True
        Exit Sub
    End If
Next i

Application.ScreenUpdating = True

End Sub
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,215,741
Messages
6,126,588
Members
449,319
Latest member
iaincmac

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