Print Command macro in Excel

Jayant

New member
Joined
Nov 23, 2017
Messages
1
Reaction score
0
Points
0
Location
Mumbai, India
I wish to create a excel macro to print only section of sheet1 on each day text is entered.
On 25th November, section of text is created in column A from Row1 to Row7. It is printed on 25th November.

On 26th November, New section of text is added in Column A from Row9 to Row15.
On giving print command on 26th November, printer should print only text added on 26th November leaving top print margin upto Row8 blank.

Idea is to print only the text added on following day without printing text of above sections.

Is there anyway, we can create a print macros to print section/sections with print command button autosetting top print margin.

This is just like Bank passbook printing done by banking software printing records from start date to end date, autosetting top margin.
 
.
Here is a small project that allows you to select what range to print. When the Input Box appears (and let's say you wanted to print range A3 to A60 and include all columns out to Column Z ).... you would enter
A3:Z60.

Code:
Option Explicit


Sub SelectPrintArea()
Dim PrintThis As Range
ActiveSheet.PageSetup.PrintArea = ""
Set PrintThis = Application.InputBox _
(Prompt:="Select the Print Range", Title:="Select", Type:=8)
PrintThis.Select
Selection.Name = "NewPrint"
ActiveSheet.PageSetup.PrintArea = "NewPrint"
ActiveSheet.PrintPreview
End Sub

Paste the above in to a Routine Module connected to a Command Button on the worksheet.
 

Attachments

  • Print User Select.xlsm
    15.9 KB · Views: 28
This is too complicated. Better:

Code:
Sub SelectPrintArea()
On Error GoTo 1 [COLOR=#008000]'There's no reason to expect the user to fill the input box properly![/COLOR]
With ActiveSheet
    .PageSetup.PrintArea =Application.InputBox ("Select the Print Range", "Select", .PageSetup.PrintArea, Type:=8)
    .PrintPreview
End With
Exit Sub
1: ... [COLOR=#008000]'the error handler[/COLOR]
End Sub

And much much better is to use a userform with the RefEdit control.

 
Back
Top