Error: Unable to set the Showdetail Property

BrotherDude

Board Regular
Joined
Sep 11, 2013
Messages
50
Hello all,

I am trying to automate a report to send tables via outlook. I am summarizing the data in a Pivot however I am getting an error as soon as it starts the first loop. I think is may be some kind of sheet naming or activation error but I'm really not sure any ideas? I've bolded the spot of the error below.

Sub WeeklyReport()


Dim rng As Range
Dim Sxbdy As Range
Dim OutApp As Object
Dim OutMail As Object
'Dim Lastrows As Range


'Sets loop
records = Application.CountA(Sheets("Pivot").Range("B:B"))
For r = 2 To records


With Application
.EnableEvents = False
.ScreenUpdating = False
End With


Cells(r, 2).ShowDetail = True
ActiveSheet.ListObjects(1).TableStyle = "TableStyleLight8"
ActiveSheet.ListObjects(1).ShowTableStyleColumnStripes = True
'Chose which collumns to include & format
Columns("A:K").EntireColumn.AutoFit
ActiveSheet.ListObjects(1).Unlist


Lastrows = Range("A" & Rows.Count).End(xlUp).Row


'Columns("D:I").NumberFormat = "_(#,##0.00_);_((#,##0.00);_(""-""_)"
Range("A:C").HorizontalAlignment = xlLeft
Cells.Font.Size = 8.5
Cells(1, 3).Select
Columns("A:K").EntireColumn.AutoFit
Set Sxbdy = Range("A1:K" & Lastrows)


Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)


On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Management Information"
.HTMLBody = RangetoHTML(Sxbdy)
.Send
End With
On Error GoTo 0


With Application
.EnableEvents = True
.ScreenUpdating = True
End With


Set OutMail = Nothing
Set OutApp = Nothing
'Set Lastrows = Nothing

Next r






End Sub


Thank you in advance
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Just needed to delete the active sheet:

Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
 
Upvote 0

Forum statistics

Threads
1,215,751
Messages
6,126,669
Members
449,326
Latest member
asp123

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