VBA : Print Specific Number Record

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all....

i'm looking for how this macro code/modify can print in specific number/record
e.q. print 2-5,8,100 etc..

here this code :
Code:
Sub PrintRecord()Dim fromRecord, toRecord, answer, i As Integer
On Error Resume Next


fromRecord = InputBox("From record", "FROM", 1)
    If fromRecord = 0 Or Not IsNumeric(fromRecord) Then Exit Sub
toRecord = InputBox("To record", "TO", fromRecord)
    If toRecord < fromRecord Or Not IsNumeric(fromRecord) Then Exit Sub
answer = MsgBox("printing records" & fromRecord & " to " & toRecord, vbOKCancel, "PRINT")
    If answer <> vbOK Then Exit Sub
    
For i = fromRecord To toRecord
    [AM8] = i
    With ActiveSheet
        .PrintOut
        .FitToPagesWide = 1
        .FitToPagesTall = 1
    End With
Next
End Sub

any help much appreciated...

m.susanto
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,215,475
Messages
6,125,028
Members
449,205
Latest member
Eggy66

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