Excellor_From_London
Board Regular
- Joined
- Aug 5, 2007
- Messages
- 50
Hi,
I've set up dynamic ranges that feed into a formula inserted via VBA below. Most of this works fine but I'm struggling to how reference the last column in the formula.
The last column is determined dynamically via the following.
Missing = Range("B1").End(xlToRight).column
However it returns the column number, not the actual column letter, e.g. if the last column is column G, it returns 7 and instead of the letter. But I need the letter of the column for the function to work. Currently all the other parameters work fine, it is just missing part that is cause the code to fall over.
Is that a way to translate a column number into the equivalent column letter?
Hope someone can suggest something.
Thanks,
Fellow Excellor
Set Regout = Range("g3") 'cell to start populating values
Lastrow = Range("B1").End(xlToRight).End(xlDown).Value
startrange = Range("A11").Value
Missing = Range("B1").End(xlToRight).column
Regout.FormulaArray = "=linest(" & "B" & startrange & ":" & "B" & lastrow & "," & "c" & startrange & ":" & MISSING & lastrow & ",true,true)"
I've set up dynamic ranges that feed into a formula inserted via VBA below. Most of this works fine but I'm struggling to how reference the last column in the formula.
The last column is determined dynamically via the following.
Missing = Range("B1").End(xlToRight).column
However it returns the column number, not the actual column letter, e.g. if the last column is column G, it returns 7 and instead of the letter. But I need the letter of the column for the function to work. Currently all the other parameters work fine, it is just missing part that is cause the code to fall over.
Is that a way to translate a column number into the equivalent column letter?
Hope someone can suggest something.
Thanks,
Fellow Excellor
Set Regout = Range("g3") 'cell to start populating values
Lastrow = Range("B1").End(xlToRight).End(xlDown).Value
startrange = Range("A11").Value
Missing = Range("B1").End(xlToRight).column
Regout.FormulaArray = "=linest(" & "B" & startrange & ":" & "B" & lastrow & "," & "c" & startrange & ":" & MISSING & lastrow & ",true,true)"