Reputation: 121
Hello I am new to excel macros
I am trying to create a simple macro which based on the current day (as I am asking this question today is Friday), find "Friday" in any row and then copy all these rows to a new sheet, I have reached this point, Any help is appreciated.
With ActiveSheet
With Range(“A1”, Range(“A” & Rows.Count).End(xlUp))
.AutoFilter 1, “Friday”
On Error Resume Next
End With
End With
Upvotes: 0
Views: 122
Reputation: 5902
You can use below logic to work this out. You need to write appropriate logic to copy the data as per your needs in the commented line.
Dim lngLastRow As Long, lngLastCol As Long, i As Long, j As Long
With ActiveSheet
lngLastRow = .Cells.Find("*", .Range("A1"), , , xlByRows, xlPrevious).Row
lngLastCol = .Cells.Find("*", .Range("A1"), , , xlByColumns, xlPrevious).Column
For i = 1 To lngLastRow
For j = 1 To lngLastCol
If .Cells(i, j).Value = Format(Now, "dddd") Then
'\\ Write Cell / Row Copying Code Here
Exit For
End If
Next j
Next i
End With
Upvotes: 1