I am trying to pass a variable into a function and it will not accept it. What is the syntax that I am missing to get it to use the variable in the worksheet function. Thanks in advanced I have been banging my head against for countless hours!
Code:
Dim VARADD As String
Dim VARSUM As String
X = 0
Do Until Cells(3, 5 + X) = "~~"
If Cells(2, 5 + X).Value > Cells(3, 2) Then
VARADD = Cells(3, 5 + X).Value
VARSUM = VARSUM & VARADD
If Cells(3, 6 + X) = "~~" Then
'nothing
Else
VARSUM = VARSUM & " , "
End If
Cells(1, 1).Value = VARSUM
Else
'nothing
End If
X = X + 1
Loop
'Cells(1, 2).Value = "=Sum(" & VARSUM & ")"
Cells(1, 4) = WorksheetFunction.Sum(1, 2, 3, 4, 5)
Cells(1, 2) = WorksheetFunction.Sum(VARSUM)'''<-- fails here (run 1004) This is what VARSUM equals at this point "26 , 6 , 29 , 4034 , 102 , 39 , 76 , 28 , 10 , 12 , 13 , 11 , 258"