Good morning, I know the following has too much "Select" in it but I needed something quick. I just don't really like it.
Some of the sheets were hidden so I unhid them but this would have applied to them all anyway.
There are variable numbers of columns in the sheets and we wanted to insert a formula that reflected the percentage of those that have been completed.
Could I have started with a "With"?
Many thanks,
D€$
Some of the sheets were hidden so I unhid them but this would have applied to them all anyway.
There are variable numbers of columns in the sheets and we wanted to insert a formula that reflected the percentage of those that have been completed.
Code:
Sub D6_Formula()
Dim ws As Worksheet
Dim MyAddress As String
Dim MyCol As Integer
For Each ws In ActiveWorkbook.Worksheets
If ws.Index > 2 And ws.Index <> ThisWorkbook.Worksheets.Count Then
Sheets(ws.Index).Select
Range("G8").Select
MyAddress = Split(Selection.End(xlToRight).Address(1, 0), "$")(0) ''End Column Letter
MyColumn = Selection.End(xlToRight).Column ''End Column Number
Range("D6").Formula = "=Sum(G8:" & MyAddress & "8)/" & MyColumn - 6
'' =SUM(G8:AD8)/24
End If
Next ws
End Sub
Could I have started with a "With"?
Many thanks,
D€$