Hello,
I have a few excel pivot tables in different sheets, which I need to be sent automatically through outlook.
How could I select the range needed, as I need to send the whole pivot table in the active sheet, but without columns that I hide.
My current Pivot table ranges from A2:J296, with D;E;F;G columns hidden. But the thing is, in other sheets, there could be less columns, less rows.
Maybe there is some way to select the columns range by the text written in the last column? (In J2 in this particular case).
Thank you!
My current code, looks like this (But it still sends with all the hidden columns, and the select range is also not dynamic):
Sub Send()
Dim x, y As String
ActiveSheet.Range("A2").Select
ActiveSheet.Range(Selection, Selection.End(xlToRight).End(xlToRight).End(xlToRight)).Select
ActiveSheet.Range(Selection, Selection.End(xlDown).End(xlDown)).Select
x = ActiveSheet.Range("M1").Value
y = ActiveSheet.Range("M2").Value
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Item.to = x
.Item.cc = y
.Item.Subject = "Client debts " & Date
.Item.Send
End With
End Sub
Bookmarks