Print Macro

Daaan

New Member
Joined
Sep 5, 2008
Messages
33
Hi guys

I have this print macro up and running.

Basically, it picks up a number in a column and puts it into a certain cell in another sheet. The sheet populates itself and then prints out autmatically.

However, it picks up 111 rows and prints them out... sometimes I don't want all rows and need to macro to stop when say "x" is found in a row.

Is there anyway I can change my current macro to incorporate this?

Here is the current code:

Sub Print_Other_Default()
For r = 4 To 115
Sheets("Other Print").Range("G4").Value = Cells(r, 1).Value
Sheets("Other Print").PrintOut
Next r
End Sub

Thanks

Dan
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi Daaan,

Try this:

Code:
Sub Print_Other_Default()
    
    For r = 4 To 115
        If Cells(r, "A").Value <> "x" Then
            With Sheets("Other Print")
                .Range("G4").Value = Cells(r, "A").Value
                .PrintOut
            End With
        Else
            Exit For
        End If
    Next r
    
End Sub

HTH

Robert
 
Upvote 0
Thanks Robert

Your macro definately stops at "x", however, I have the macro as a button on the sheet that I am printing "13.Special Case Calc" and it picks up the data from sheet "other print".

your macro is printing out the sheet "other print"

Do you know how I would correct his?

Thanks

Dan
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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