Oct 18 2023 05:32 AM
Hello, I have some coding which filters some columns to find data I need to add a comment against, then writes the comment and fills it down to the bottom. However, the Filldown isn't working. Everything works fine up until that point, once it gets to the Selection.filldown, it just doesn't do anything, there is no error message it just doesn't do anything. Any ideas what I am missing? Thanks
Sub Description()
Dim lastRow As Long
lastRow = Cells(Rows.Count, "AB").End(xlUp).Row
Range("AB1:AB" & lastRow).Offset(1, 0).SpecialCells(xlCellTypeVisible).Areas(1).Rows(1).Select
Sheets("Data").Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Sheets.Add After:=ActiveSheet
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cells.Select
Cells.EntireColumn.AutoFit
Columns("D:D").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Range("O1").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("Sheet2").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet2").AutoFilter.Sort.SortFields.Add2 Key:= _
Range("O1:O58100"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet2").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.Range("$A$1:$BK100000").AutoFilter Field:=15, Criteria1:= _
"Required"
ActiveSheet.Range("$A$1:$BK100000").AutoFilter Field:=28, Criteria1:= _
""
Range("AB1:AB" & lastRow).Offset(1, 0).SpecialCells(xlCellTypeVisible).Areas(1).Rows(1).Select
ActiveCell.FormulaR1C1 = "Completed"
Range("AB1:AB" & lastRow).Offset(1, 0).SpecialCells(xlCellTypeVisible).Areas(1).Rows(1).Select
Selection.filldown
End Sub
Oct 18 2023 05:40 AM
The instruction
Range("AB1:AB" & lastRow).Offset(1, 0).SpecialCells(xlCellTypeVisible).Areas(1).Rows(1).Select
selects a single cell. So there is nothing to fill down.
Oct 18 2023 05:54 AM
Oct 18 2023 06:02 AM
Please explain what you want to do - it's difficult to follow the code.
Oct 18 2023 06:03 AM
Oct 18 2023 07:49 AM
Does this work?
Sub Description()
Dim w1 As Worksheet
Dim w2 As Worksheet
Dim lastRow As Long
Application.ScreenUpdating = False
Set w1 = Worksheets("Data")
w1.Cells.Copy
Set w2 = Worksheets.Add(After:=w1)
w2.Range("A1").PasteSpecial Paste:=xlPasteValues
lastRow = w2.Cells(w2.Rows.Count, "AB").End(xlUp).Row
Application.CutCopyMode = False
w2.Cells.EntireColumn.AutoFit
w2.Columns("D:D").Delete Shift:=xlToLeft
w2.Range("O1").AutoFilter
With w2.AutoFilter.Sort
.SortFields.Clear
.SortFields.Add2 Key:=Range("O1"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.Apply
End With
w2.Range("$A$1:$BK100000").AutoFilter Field:=15, Criteria1:="Required"
w2.Range("$A$1:$BK100000").AutoFilter Field:=28, Criteria1:=""
w2.Range("AB2:AB" & lastRow).SpecialCells(xlCellTypeVisible).Value = "Completed"
Application.ScreenUpdating = True
End Sub