I am trying to create a fairly complex macros for reports that I do at work.
We are currently using macros and this accomplishes about 70% of what we would like to do. Here is our current macros:
Sub AddSheets()
Application.ScreenUpdating = False
'Sort data on "Formatting - Deltek" worksheet by names in column Q
Application.Goto Reference:="R7C1:R65536C24"
ActiveWorkbook.Worksheets("Formatting - Deltek").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Formatting - Deltek").Sort.SortFields.Add Key:= _
Range("Q7:Q65536"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Formatting - Deltek").Sort
.SetRange Range("A7:W65536")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
Dim rng As Range
With Sheets("Formatting - Deltek")
.AutoFilterMode = False
Sheets.Add().Name = "Temp"
.Range("Q6", .Range("Q6").End(xlDown)).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sheets("Temp").Range("A1"), Unique:=True
For Each rng In Sheets("Temp").UsedRange.Offset(1).Resize(Sheets("Temp").UsedRange.Rows.Count - 1)
.Range("A7").CurrentRegion.AutoFilter field:=17, Criteria1:=rng
Sheets.Add(After:=Sheets(Sheets.Count)).Name = rng
.AutoFilter.Range.Copy Sheets(rng.Text).Range("A1")
Next rng
.AutoFilterMode = False
Application.DisplayAlerts = False
Sheets("Temp").Delete
Application.DisplayAlerts = True
End With
Dim wsheet As Worksheet
Dim Last_Row As Long
For Each wsheet In Sheets
If wsheet.Name <> "Sub Query" And wsheet.Name <> "LDSUBREC (Voucher Query)" And wsheet.Name <> "Formatting - Deltek" Then
Sheets("Formatting - Deltek").Rows("1:5").Copy
wsheet.Rows(1).Insert
wsheet.Columns("A:G").ColumnWidth = 17
wsheet.Columns("H:K").ColumnWidth = 10
wsheet.Columns("L:N").ColumnWidth = 7
wsheet.Columns("O:O").ColumnWidth = 13
wsheet.Columns("P:P").ColumnWidth = 10
wsheet.Columns("Q:Q").ColumnWidth = 7
wsheet.Columns("R:R").ColumnWidth = 20
wsheet.Columns("S:S").ColumnWidth = 17.14
wsheet.Columns("T:T").ColumnWidth = 12
wsheet.Columns("U:W").ColumnWidth = 10
wsheet.Rows(6).RowHeight = 32.25
wsheet.Range("Q7").Copy
wsheet.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
Last_Row = wsheet.Range("D65536").End(xlUp).Row
wsheet.Range("D" & Last_Row + 1).Formula = "=Sum(D7:D" & Last_Row & ")"
With wsheet.Range("D65536").End(xlUp)
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlDouble
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThick
End With
With .Font
.Name = "Calibri"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
End With
End If
Next wsheet
Application.ScreenUpdating = True
End Sub
This takes a list of information and breaks it out into tabs in Excel based on the names as well as formats them. There is one problem with this. After this break-down happens I need to further break down those tabs based on another column containing invoice numbers. So for example I would have the following tab titles (Apple (Invoice 1), Apple (Invoice 2), Microsoft (Invoice 1), Microsoft (Invoice 2)). Is there anyone that could help me?
Thanks,
Sean
Bookmarks