How to include ActiveSheet “B2” Value to PrintOut?

Big Lar

Well-known Member
Joined
May 19, 2002
Messages
557
How to include ActiveSheet “B2” Value to PrintOut?

Code:
       Range(Cells(i, 2), Cells(i, 3)).PrintOut
         
    End With
    End If
Next i
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Maybe
Range(Cells(i, 2), Cells(i, 3)) & ActiveSheet.Range("B2").PrintOut
 
Upvote 0
Thanks, Micron.
"&" results in Syntax Error.

Maybe a review of the entire Sub can shed some light?
Code:
Private Sub CommandButton3_Click()
Dim myrange As String
Dim lr As Long
Dim oneDriveFolder As String
Dim obCB As OLEObject, i As Integer
  
With ActiveSheet
   lr = .Range("A" & .Rows.Count).End(xlUp).Row
   .Range("T" & lr).Value = " "
End With
  
For i = 3 To 50

    Set obCB = ThisWorkbook.ActiveSheet.OLEObjects("CheckBox" & i)
   
   With ActiveSheet
    If Cells(i, 3).Value = 0 Then
            obCB.Object = True
    End If
    End With

    If obCB.Object.Value = False Then
    
    With ActiveSheet.PageSetup
        .Zoom = 125
        .LeftMargin = Application.InchesToPoints(0)
        .TopMargin = Application.InchesToPoints(4)
        .Orientation = xlPortrait
        
        Range(Cells(i, 2), Cells(i, 3)).PrintOut
        
    End With
    End If
    
Next i
End Sub
[Code/]
 
Upvote 0
It concatenated correctly for me in the immediate window. Perhaps post how you tried to implement it, because that is not shown in that code.
 
Upvote 0
Micron,
The VBA is used to print “Payment Vouchers” for all individuals whose CheckBox is unchecked.
Cells(i,2) is the recipient’s name
Cells(i,3) is the payment amount
Embedded Command Button 3 on the active worksheet runs the Sub.
It’s been working just fine for over 10 years.

My recent enhancements to the project have improved some minor readability issues associated with the “Reports” formats. Adding B2 value to the Payment Vouchers printouts would be one of those minor enhancements.

My attempts to include B2 value to the Printout Line have produced various Syntax and Run-Time errors:
“Object Doesn’t Support This Property or Method”

Since no recipient has complained, I’m ready to throw in the towel and abandon this “enhancement”.
Thanks for looking!
 
Upvote 0
Well. you can always come back if you need another feather in your cap. But do post the code and identify the line(s) that trigger errors if you do, otherwise there's not much to guide anyone.
 
Upvote 0
VBA Code:
Range("B2," & Range(Cells(i, 2), Cells(i, 3)).Address).PrintOut 1
But it prints on 2 pages probably as it is a non-contiguous range (at least here it does, I am printing to PDF as not currently linked to a printer).

To get it to print on one page as far as I can see you would need to set the print area to cover the whole area and then hide the rows between B2 and the data entry to print, or copy everything you need to a helper sheet and then print and clear that sheet
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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