I use an addon to pull 62 reports out of Salesforce.com into Excel. The addon puts each report onto a separate tab in a worksheet (which is perfect). Previously, I was copying and pasting into another worksheet that was a mirror copy, except it had tables set up on each tab. I am looking for a way to cut down on my copying and set up a macro that would automatically select the range on a tab, create a table, and continue across all 62 tabs. The problem I run into is each tab contains a variable amount of rows.
Part of my formatting macros have a range down to row 580, which is a safe distance for me to format specific cells for purposes of text color. As I have been hobbling around trying to create the tables, this compounds what I have as it creates the table all the way down to row 580. If there is a way to select only cells that have data in them for specific columns (minus Row A which would be the table header), that would work too. I only need the table to encompass the rows that contain information.
I have submitted the current macro I use:
Sub SAR_Format()
'
' SAR_Format Macro
' SAR Table Formating
'
'
Dim ws As Worksheet
For Each ws In Sheets
ws.Activate
Columns("A:A").EntireColumn.AutoFit
Columns("B:B").EntireColumn.AutoFit
Columns("C:G").Select
Selection.ColumnWidth = 7.86
Selection.ColumnWidth = 10
Columns("H:H").Select
Columns("H:H").EntireColumn.AutoFit
Columns("I:I").EntireColumn.AutoFit
Columns("J:J").EntireColumn.AutoFit
Columns("K:K").EntireColumn.AutoFit
Columns("L:L").ColumnWidth = 8.86
Columns("L:L").ColumnWidth = 7.57
Rows("1:1").RowHeight = 29.25
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("M:M").EntireColumn.AutoFit
Columns("N:N").EntireColumn.AutoFit
ActiveWindow.ScrollColumn = 2
Columns("N:N").EntireColumn.AutoFit
Columns("O:O").EntireColumn.AutoFit
Columns("P:P").EntireColumn.AutoFit
ActiveWindow.ScrollColumn = 1
Range("C2:G580").Select
Selection.NumberFormat = "$#,##0_);[Red]($#,##0)"
With Selection.Font
.Color = -65536
.TintAndShade = 0
End With
Range("A2:P580").Select
With Selection.Font
.Name = "Calibri"
.Size = 10
End With
ActiveWindow.SmallScroll Down:=-348
ActiveWindow.ScrollRow = 191
ActiveWindow.ScrollRow = 189
ActiveWindow.ScrollRow = 186
ActiveWindow.ScrollRow = 184
ActiveWindow.ScrollRow = 179
ActiveWindow.ScrollRow = 174
ActiveWindow.ScrollRow = 167
ActiveWindow.ScrollRow = 159
ActiveWindow.ScrollRow = 149
ActiveWindow.ScrollRow = 141
ActiveWindow.ScrollRow = 133
ActiveWindow.ScrollRow = 124
ActiveWindow.ScrollRow = 118
ActiveWindow.ScrollRow = 89
ActiveWindow.ScrollRow = 86
ActiveWindow.ScrollRow = 82
ActiveWindow.ScrollRow = 79
ActiveWindow.ScrollRow = 76
ActiveWindow.ScrollRow = 74
ActiveWindow.ScrollRow = 71
ActiveWindow.ScrollRow = 70
ActiveWindow.ScrollRow = 67
ActiveWindow.ScrollRow = 65
ActiveWindow.ScrollRow = 63
ActiveWindow.ScrollRow = 48
ActiveWindow.ScrollRow = 45
ActiveWindow.ScrollRow = 43
ActiveWindow.ScrollRow = 40
ActiveWindow.ScrollRow = 38
ActiveWindow.ScrollRow = 35
ActiveWindow.ScrollRow = 32
ActiveWindow.ScrollRow = 30
ActiveWindow.ScrollRow = 28
ActiveWindow.ScrollRow = 26
ActiveWindow.ScrollRow = 25
ActiveWindow.ScrollRow = 23
ActiveWindow.ScrollRow = 20
ActiveWindow.ScrollRow = 18
ActiveWindow.ScrollRow = 16
ActiveWindow.ScrollRow = 15
ActiveWindow.ScrollRow = 13
ActiveWindow.ScrollRow = 11
ActiveWindow.ScrollRow = 10
ActiveWindow.ScrollRow = 9
ActiveWindow.ScrollRow = 8
ActiveWindow.ScrollRow = 6
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 2
Next ws
End Sub
This macro fixes my column widths, gives my the appropriate font size, format, and color for specific cells, but does not create the table.