I am trying to create a macro that will run If statements on every sheet with “(M)” at the end. I just need the macro to check cell “G8” in every worksheet with “(M)” at the end to see if there is a formula. If there is, then copy the formula over to “M8”. If there isn’t a formula then move on to the next sheet. Right now, the macro is doing nothing. I need it to work on all sheets with (M) at the end because this is a workbook where new sheets will be added and current sheets may be deleted, and I would like for the macro to work without having to change it when the sheets are changed.
Sub MondayCalc()
Application.ScreenUpdating = False
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name Like "*(M)" Then
If ws.Range("G8").HasFormula = True Then
ws.Range("G8").Select
ws.Selection.AutoFill Destination:=ws.Range("G8:M8"), Type:=xlFillValues
ws.Range("H8:M8").Select
ws.Selection.Copy
ws.Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End If
ws.Range("A8").Select
End If
Next ws
End Sub
This is what my current code looks like. Any help would be greatly appreciated!
Nick Speake is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.