I am trying to figure out the correct syntax so that my String variable colLetter will be evaluated within the SUM workbookfunction instead of being read as the literal text "colLetter".
colLetter stores Strings within a loop for each column range: "A:A", then "B:B", "C:C" and so on...
I have a function Col_Letter(integer) As String that takes an integer and returns the String of the column letter in excel that integer corresponds to. Example: Col_Letter(3) returns "C"
Right now my loop looks like so:
For c = 3 To lastColumn
Dim colLetter As String
colLetter = Col_Letter(c) & ":" & Col_Letter(c)
Cells(lastRow + 1, c).Formula = "=SUM(colLetter)"
Next
I want the formula to return =SUM("A:A"), =SUM("B:B") etc...but it returns =SUM(colLetter) instead and thus #Value!
I can't figure out what needs to be fixed with my syntax of the sum formula. Any help would be much appreciated!