Hi,
Here are 2 proposal :
With a formula. Example in B66 = YTD(B66)
(note that it does not refresh automatically)
Function YTD(rg As Range) As String
Dim arSh, i
Application.Volatile
arSh = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
arSh = Split(arSh, ",")
On Error Resume Next '(in case a sheet is not found)
For i = LBound(arSh) To UBound(arSh)
YTD = YTD & IIf(Sheets(arSh(i)).Range(rg.Address) = "Yes", 1, 0)
Next i
On Error GoTo 0
End Function
Or with a sub
(Adjust range / sheet names are necessary)
Sub YTD2()
Dim arSh, i
Dim rg As Range, c As Range
Dim sYTD As String
Application.Volatile
arSh = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
arSh = Split(arSh, ",")
Set rg = Sheets("YTD").Range("B66:K75")
For Each c In rg
sYTD = "'"
On Error Resume Next '(in case a sheet is not found)
For i = LBound(arSh) To UBound(arSh)
sYTD = sYTD & IIf(Sheets(arSh(i)).Range(c.Address) = "Yes", 1, 0)
Next i
On Error GoTo 0
c.Value = sYTD
Next c
End Sub
Bookmarks