Hi -
I need help with the code for a button - it will run this macro...the first part runs fine on its own where it exports the spreadsheets to a file with 4 tabs. I wanted the file to also be formatted. I ran a macro recorder in Excel to get the code and altered it shortly, but the debugger is giving me errors. PLEASE HELP
Thank you for your help!
Megan
Private Sub Command136_Click()
Call DoCmd.TransferSpreadsheet(TransferType:=acExport, _
TableName:="APL Tracker Query", _
FileName:="C:\Users\mfrey\Desktop\TRANSFER\Databas es\APL Database\Reports\APL Tracker (COMPLETE) " & Format(Date, "mm-dd-yyyy") & ".xlsx")
Call DoCmd.TransferSpreadsheet(TransferType:=acExport, _
TableName:="qryTrackerDrew", _
FileName:="C:\Users\mfrey\Desktop\TRANSFER\Databas es\APL Database\Reports\APL Tracker (COMPLETE) " & Format(Date, "mm-dd-yyyy") & ".xlsx")
Call DoCmd.TransferSpreadsheet(TransferType:=acExport, _
TableName:="qryTrackerGreg", _
FileName:="C:\Users\mfrey\Desktop\TRANSFER\Databas es\APL Database\Reports\APL Tracker (COMPLETE) " & Format(Date, "mm-dd-yyyy") & ".xlsx")
Call DoCmd.TransferSpreadsheet(TransferType:=acExport, _
TableName:="qryTrackerNelson", _
FileName:="C:\Users\mfrey\Desktop\TRANSFER\Databas es\APL Database\Reports\APL Tracker (COMPLETE) " & Format(Date, "mm-dd-yyyy") & ".xlsx")
With Selection.Font
.Name = "Tahoma"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.Name = "Tahoma"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection
.HorizontalAlignment = xlGeneral
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Worksheet.Columns("A:E").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Worksheet.Columns("G:H").Select
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
Worksheet.Range("G:H,S:V,W:W,X1,X:X,O:O,N:N,R:R"). Select
Worksheet.Range("R1").Activate
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Worksheet.Range("N1").Select
ActiveCell.FormulaR1C1 = "Config."
Worksheet.Range("N2").Select
Worksheet.Columns("K:K").ColumnWidth = 32.14
Worksheet.Columns("J:J").ColumnWidth = 24.29
Worksheet.Columns("I:I").ColumnWidth = 17.14
Worksheet.Columns("F:F").ColumnWidth = 15.57
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
Worksheet.Columns("L:M").Select
Selection.ColumnWidth = 13.43
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Worksheet.Columns("Q:Q").ColumnWidth = 26
Worksheet.Columns("P:P").ColumnWidth = 26.43
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
Worksheet.Columns("Y:Y").ColumnWidth = 25.86
Worksheet.Range("S1:Y1").Select
Worksheet.Range("Y1").Activate
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Worksheet.Rows("1:1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Worksheet.Range("J2").Select
ActiveWindow.FreezePanes = True
Worksheet.Range("A1:O1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent5
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With
Worksheet.Range("S1:Y1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent5
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With
Worksheet.Columns("P:R").Select
Worksheet.Range("R1").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Worksheet.Range("F4").Select
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
Worksheet.Range("C2").Select
ActiveWindow.SmallScroll Down:=-12
Worksheet.Range("D3").Select
Worksheet.Sheets("qryTrackerDrew").Select
Worksheet.Cells.Select
With Selection.Font
.Name = "Tahoma"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.Name = "Tahoma"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Worksheet.Columns("A").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Worksheet.Sheets(Array("qryTrackerDrew", "qryTrackerGreg", "qryTrackerNelson")).Select
Worksheet.Sheets("qryTrackerDrew").Activate
Worksheet.Columns("A").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Font
.Name = "Tah]"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.Name = "Tahoma"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Worksheet.Columns("A").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Worksheet.Cells.Select
With Selection
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Worksheet.Range("J2").Select
Worksheet.Columns("J:J").ColumnWidth = 52.29
Worksheet.Columns("I:I").ColumnWidth = 35.86
Worksheet.Columns("H:H").ColumnWidth = 24.71
Worksheet.Columns("F:G").Select
Worksheet.Selection.ColumnWidth = 13
Worksheet.Columns("E:E").Select
Worksheet.Selection.ColumnWidth = 24.86
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
Worksheet.Range("K:L,S:S,N:O,P:P").Select
Worksheet.Range("P1").Activate
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
With Selection
.HorizontalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Worksheet.Range("Q2").Select
Worksheet.Columns("Q:Q").ColumnWidth = 33
Worksheet.Columns("R:R").ColumnWidth = 34.86
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Worksheet.Cells.Select
Worksheet.Cells.EntireRow.AutoFit
Worksheet.Range("I2").Select
ActiveWindow.FreezePanes = True
Worksheet.Range("A1:P1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent5
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 17
Worksheet.Columns("Q:S").Select
Worksheet.Range("S1").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
Worksheet.Cells.Select
With Selection
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Worksheet.Range("F5").Select
Worksheet.Sheets(Array("qryTrackerDrew", "qryTrackerGreg", "qryTrackerNelson")).Select
Worksheet.Sheets("qryTrackerGreg").Activate
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
Worksheet.Sheets(Array("qryTrackerDrew", "qryTrackerGreg", "qryTrackerNelson")).Select
Worksheet.Sheets("qryTrackerNelson").Activate
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
Worksheet.Sheets(Array("qryTrackerDrew", "qryTrackerGreg", "qryTrackerNelson")).Select
Worksheet.Sheets("qryTrackerDrew").Activate
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
Worksheet.Range("K1:P1").Select
Worksheet.Range("P1").Activate
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Worksheet.Range("M2").Select
Worksheet.Columns("M:M").ColumnWidth = 36.71
Worksheet.Range("M4").Select
Worksheet.Sheets(Array("qryTrackerDrew", "qryTrackerGreg", "qryTrackerNelson")).Select
Worksheet.Sheets("qryTrackerDrew").Activate
Worksheet.Cells.Select
With Selection.Font
.Name = "Tahoma"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.Name = "Tahoma"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Worksheet.Sheets(Array("qryTrackerDrew", "qryTrackerGreg", "qryTrackerNelson")).Select
Worksheet.Sheets("qryTrackerDrew").Activate
Worksheet.Columns("K:L").Select
Selection.ColumnWidth = 11.86
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
Worksheet.Columns("N:P").Select
Worksheet.Range("P1").Activate
Selection.ColumnWidth = 8.57
Worksheet.Sheets(Array("qryTrackerDrew", "qryTrackerGreg", "qryTrackerNelson")).Select
Worksheet.Sheets("qryTrackerDrew").Activate
Worksheet.Rows("1:1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 17
Worksheet.Range("A1:S1").Select
Worksheet.Range("S1").Activate
Selection.Font.Bold = True
Worksheet.Sheets("APL Tracker Query").Select
Worksheet.Rows("1:1").Select
Selection.Font.Bold = True
Worksheet.Range("I5").Select
ActiveWindow.SmallScroll Down:=-15
End Sub