second Q here, still learning but trying to do my best!
Question:
I want to run a macro which takes the name of a sheet (it is the active sheet at that moment) and uses it to delete every row in sheet "PD" which contains the name of that "previous active sheet" in column "M". Than the macro should go back to that "previous active sheet" and fill some cells with color (that part should be ok)
I tried a couple of things and with help of other topics below and the record button i managed to get this code, which doesn't work
Sub FindandDelete
Sheets("PD").Select
Range("M").Select
With ActiveSheet
.AutoFilterMode = False
With Range("M1", Range("M" & Rows.Count).End(xlUp))
.AutoFilter 1, ActiveSheet.Previous.Name.Select
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
ActiveSheet.Previous.Select
Range("N16,N17").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("A1").Select
End Sub
For activate sheet: How to activate a specific worksheet in Excel
Hope that anyone can help, if more effort or explanation needed, happy to hear.