I have 3 open workbooks, I want to filter based on the message box criteria, then copy the filtered values for each workbook over to another workbook based on the next empty row.
The code before I inserted the filter section worked fine, now it filters but copy only the first workbook.
Please assist me to fix and understand what I did wrong in the below code?
Code:
I may have posted a similar question in another group but no one was able to answer.
The code before I inserted the filter section worked fine, now it filters but copy only the first workbook.
Please assist me to fix and understand what I did wrong in the below code?
Code:
VBA Code:
Sub updateCurRevenue()
Dim sNames As Variant
sNames = Array("Jas.xlsm", "Tees.xlsm", "Books.xlsm")
Dim wb As Workbook
Set wb = ActiveWorkbook
With wb.Worksheets("Data")
Dim dFirst As Range
Set dFirst = .Cells(.Rows.Count, "A").End(xlUp).Offset(1)
End With
Dim dCell As Range
Set dCell = dFirst
Dim sName As Variant
Dim sLastRow As Long
Dim sRng As Range
Dim dRows As Long
Dim i As String
i = InputBox("Last actual 'RED' Date")
For Each sName In sNames
With Workbooks(sName).Worksheets("Names")
sLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Selection.AutoFilter
.Range("A2:N" & sLastRow).AutoFilter field:=12, Criteria1:=">" & i
Set sRng = .SpecialCells(xlCellTypeVisible).Copy
End With
With sRng
dCell.Resize(.Rows.Count, .Columns.Count).Value = sRng.Value
dRows = dRows + .Rows.Count
Set dCell = dCell.Offset(.Rows.Count)
End With
Next sName
With dFirst.Resize(dRows, sRng.Columns.Count)
.Interior.Color = xlNone
With .Font
.Name = "Arial"
.Size = 10
End With
End With
End Sub
I may have posted a similar question in another group but no one was able to answer.
Last edited by a moderator: