vba help - merge two range data into PDF printable area

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
983
Office Version
  1. 2010
Platform
  1. Windows
Hi Team,

Need your help, I want to print excel data into pdf. all data is not coming in printable area. I want all data to club.

I want both the data range into PDF.

IF Possible can we increase column width of First range to match with second data set.


This is my below data and attached snapshot.





Book1.xlsm
ABCDEFGHIJKLMNOPQRSTU
1
2
3Amounts in USD
4
5YearTotalY1Y2Y3Y4Y5
6HEADERSAAAxxxAAAxxxAAAxxxAAAxxxAAAxxxAAAxxx
7Amount21000100020003000400050006000
8
9
10
115 Years Data Cumulative
12
13TotalAUDCNYEURGBPHKDJPYOTHSGDUSD
14aaaxxxaaaxxxaaaxxxaaaxxxaaaxxxaaaxxxaaaxxxaaaxxxaaaxxxaaaxxx
1554002003004005006007008009001000
16
17
Sheet1




Found One code on google.. it is removing borders.
VBA Code:
Sub PrintArea()

Application.ScreenUpdating = False

Dim ws As Worksheet


With ActiveSheet
   If .VPageBreaks.Count > 0 Then
      .VPageBreaks(1).Delete
   End If
End With


For Each ws In ActiveWorkbook.Worksheets

    Select Case ws.Index

        Case Is = 1, 2, 3, 4, 5, 6 'only perform action on first 6 sheets

            'If ws.Range("A25") = "Yes" Then 'adjust to desired range and indicator

                With ws.PageSetup
                    .PrintArea = ws.Range("A1:u17").Address
                    .Orientation = xlLandscape
                    .FitToPagesWide = 1
                    .FitToPagesTall = 1
                End With

                'set print area to only 1 page
                With ws
                    .Activate 'need to activate sheet to view Page Break Preview
                    ActiveWindow.View = xlPageBreakPreview 'need to view Page Break Preview to drag page breaks
                    .VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1 'drag page over so it's just one page
                    ActiveWindow.View = xlNormalView 'set view back to normal
                End With

           ' End If

    End Select

Next ws


End Sub




Thanks
mg
 

Attachments

  • Data Snapshot.png
    Data Snapshot.png
    24.2 KB · Views: 7

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi Team,

Below line of code is stretching , and bringing all data into printable.
.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1

But borders are not showing in printable area.

When I clicked on print preview , it is showing like this it removed border lines from middles.
1644576296786.png


Thanks
mg
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

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