Hello community,
I created a macro (the non professional way - i.e. didn't write the VBA myself) that copies data from one sheet into another and then applies a series of sorts and filters to come up with a "report" for our office.
The macro was running fine for a few weeks/months, but now somehow all of the data from the first sheet is not being brought into the data copied in the final sheet.
In the main sheet, new rows are constantly being added and it seems to bring in all rows that are inserted between rows, but not rows that have been added. Meaning, if I had rows 1-10, but at row 3, I inserted a new row, the macro would bring in that row into
the final sheet. However, if I add a row 11, that will not be brought in. I believe that is what is happening based on the final product in the final sheet.
I have copied the VBA code below. Any insight would be appreciated and thank you.
Sub clipboard()
'
' clipboard Macro
'
' Keyboard Shortcut: Ctrl+m
'
Sheets("CLIPBOARD").Select
Cells.Select
Selection.Delete Shift:=xlUp
Selection.ClearContents
Selection.Delete Shift:=xlUp
Sheets("MasterLog10.20.10").Select
Cells.Select
Selection.Copy
Sheets("CLIPBOARD").Select
ActiveSheet.Paste
Columns("A:A").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("E:E").Select
Selection.Cut
Columns("A:A").Select
ActiveSheet.Paste
Columns("D:D").Select
Selection.Cut
Columns("D:F").Select
Application.CutCopyMode = False
Selection.Cut
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 18
ActiveWindow.ScrollColumn = 19
ActiveWindow.ScrollColumn = 20
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 23
Columns("AG:AG").Select
ActiveSheet.Paste
Columns("AH:AH").Select
Selection.Delete Shift:=xlToLeft
Columns("AA:AF").Select
Range("AF1").Activate
Selection.Delete Shift:=xlToLeft
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 20
ActiveWindow.ScrollColumn = 19
ActiveWindow.ScrollColumn = 18
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
Columns("N:P").Select
Selection.Delete Shift:=xlToLeft
Columns("R:T").Select
Selection.Delete Shift:=xlToLeft
Columns("T:T").Select
Selection.Delete Shift:=xlToLeft
Columns("S:S").Select
Selection.Cut
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 1
Columns("D:D").Select
ActiveSheet.Paste
Columns("E:F").Select
Selection.Delete Shift:=xlToLeft
Columns("G:I").Select
Selection.Delete Shift:=xlToLeft
Columns("K:L").Select
Selection.Delete Shift:=xlToLeft
Columns("L:L").Select
Selection.Delete Shift:=xlToLeft
Cells.Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Rows("1:1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent3
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Columns("A:A").Select
With Selection
.HorizontalAlignment = xlCenter
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlGeneral
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Dim lngRow As Long
lngRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
ActiveWorkbook.Worksheets("CLIPBOARD").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("CLIPBOARD").Sort.SortFields.Add Key:=Range( _
"F2:F" & lngRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("CLIPBOARD").Sort.SortFields.Add Key:=Range( _
"A2:A" & lngRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("CLIPBOARD").Sort
.SetRange Range("A8:M" & lngRow)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AJ$" & lngRow).AutoFilter Field:=9, Criteria1:=Array( _
"Active", "Active file", "Meeting Agenda", "Meeting Meeting Agenda", "Unclaimed", _
"="), Operator:=xlFilterValues
Columns("I:I").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.Range("$A$1:$AJ$" & lngRow).AutoFilter Field:=10, Criteria1:="="
Columns("J:J").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.Range("$A$1:$AJ$" & lngRow).AutoFilter Field:=7, Criteria1:= _
"Pending"
Columns("G:G").Select
Selection.EntireColumn.Hidden = True
Range("C82").Select
Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "Date report generated"
Range("B1").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
Range("B1").Select
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
With Selection.Font
.Name = "Arial"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.Color = -16776961
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("A1").Select
Selection.Font.Italic = True
With Selection.Font
.Name = "Arial"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Cells.Select
With Selection.Font
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("A1:B1").Select
Range("B1").Activate
With Selection.Font
.Name = "Arial"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("D83").Select
End Sub