• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

changing cell value while printing by button original duplicate triplicate

MR.Mewada

New Member
Hello
I want to change value of cell M2 while printing by print button change value only in cell M2
as Original , Duplicate, Triplicate i tried this code but error is coming please help on this
thanks
Code:
Sub Button1_Click()
Dim n As Long
n = Application.InputBox("Number of printed copies.?", "Printed Copies", 1, Type:=1)
If n <= 0 Then Exit Sub ' User canceled
With ActiveSheet.PageSetup
.Sheets("Sheet1").Range("M2") = "Original"
ActiveSheet.PrintOut
If n > 1 Then
.Sheets("Sheet1").Range("M2") = "Duplicate"
ActiveSheet.PrintOut
End If
If n > 2 Then
.Sheets("Sheet1").Range("M2") = "Triplicate"
ActiveSheet.PrintOut
End If
End With
End Sub

Mod Edit: Code Tags Added.
 
Last edited by a moderator:
Your code will error out on lines like below:
Code:
.Sheets("Sheet1").Range("M2") = "Original"
Remove preceding dot and see if it works.
Code:
Sheets("Sheet1").Range("M2") = "Original"
 
Back
Top