So I am learning VBA basics and have run into a problem. Basically I want to create a macro that formats and sums some weekly data. I want it to also automatically apply to each newly created worksheet within the workbook as the weeks go on and I add more data. Currently what I have will apply the formats to all worksheets within the workbook but when I add a new one I have to run the macro again. But when I do that it runs it over the previous worksheets as well creating multiple of the same headers and multiple sums of the same data. I'm not sure what I can do to have the macro automatically run whenever data is added to a new sheet or have it not run over sheets it has already applied changes to.
Dim lastcell As String
Dim x As Integer
x = 1
Do While x <= Worksheets.Count
Worksheets(x).Select
Range("F2").Select
Selection.End(xlDown).Select
lastcell = ActiveCell.Address(False, False)
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = "=SUM(F2: " & lastcell & ")"
x = x + 1
Loop
End Sub
Again I am very much a beginner here so any help is greatly appreciated!!!