Excel Pivot table & Mail Merge

sunilkovid

New Member
Joined
Jul 8, 2018
Messages
2
Hai There,

I'm using a code where I can able to send the pivot table in the body of email using mail merge. But I'm getting a lot of blank space between my pivot table and signature.

I had hidden all the rows by taking the referance of Grand total in the pivot but still i'm getting the blank space underneath.

Macro :

Sub Kovid()

Application.DisplayAlerts = False

Dim r As Range
Set r = Sheets("Pivot").Cells

Dim i As Integer

Dim last_row As Integer

last_row = Application.WorksheetFunction.CountA(Sheets("Mail ID's").Range("A:A"))

For i = 2 To last_row


Range("B1").Select

ActiveSheet.PivotTables("PivotTable1").PivotFields("AIDebitAccountNo"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("AIDebitAccountNo"). _
CurrentPage = Sheets("Mail ID's").Range("A" & i).Value

ActiveWorkbook.EnvelopeVisible = True

With r.Parent.MailEnvelope.Item

.to = Sheets("Mail ID's").Range("b" & i).Value
.cc = Sheets("Mail ID's").Range("c" & i).Value
.Subject = Sheets("Mail ID's").Range("J2").Value
.send
End With


Next i


End Sub


-----------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Application.ScreenUpdating = False
Cells.EntireRow.Hidden = False
Range("theGap").EntireRow.Hidden = True
Application.ScreenUpdating = True
End Sub
-------------------------------------------------------------




Thanks in advance...
smile.gif
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

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