Hi
Try this.
Sub WhatsWrong()
Dim i As Integer, j As Integer, k As Integer
Dim eName As String, SaTotal As String
For j = 3 To 15
SaTotal = "=Sum(" '*** changed
For i = 4 To ThisWorkbook.Sheets("Master Edit").Range("C" & Rows.Count).End(xlUp).Row
eName = ThisWorkbook.Sheets("Master Edit").Range("C" & i).Value '********** Change here
SaTotal = SaTotal & eName & "!$B$" & j & "," '***change
Next i
k = j + 1
ThisWorkbook.Sheets("Master Edit").Range("A1").Select 'trying to get the activesheet
SaTotal = Left(SaTotal, Len(SaTotal) - 1) & ")" '*** new line
MsgBox "The resulting formula for cell (F" & k & ")" & SaTotal
With ActiveSheet
' .Range(k, 6).Value = SaTotal
.Cells(k, 6).Formula = SaTotal '*** new line
' .Cell(k, 6).Value = SaTotal
' .Range("F" & k).Value = SaTotal
End With
' ThisWorkBook.Sheets("Annual Report").Range("F" & k).Value = SaTotal
Next j
End Sub
rylo
Bookmarks