I've been staring at my screen trying to fix this for quite some time. Mabye a fresh look by others
will help. I have a script which allows the person running the macro to select a cell, and the idea is that the the column
letter is printed in a designated cell (which will not user defineable, but that's not important now.)
Untill now I'm working with a function provided by microsoft to convert numbers to letters. This script works on it's own,
the script I use for extracting the column number aswell, but when put together, I get no output in the designated cell.
The code is posted here, I hope somebody can help me out, I feel like I've tried everything.
Dim UserRange As Range
Dim ColNum As Integer
Dim Output As Variant
Output = ConvertToLetter(ColNum)
Prompt = "Select a cell for the output."
Title = "Select a cell"
On Error Resume Next
Set UserRange = Application.InputBox( _
ColNum = ActiveCell.Range("A1").Column
If UserRange Is Nothing Then
ActiveCell.FormulaR1C1 = Output
Function ConvertToLetter(iCol As Integer) As String
Dim iAlpha As Integer
Dim iRemainder As Integer
iAlpha = Int(iCol / 27)
iRemainder = iCol - (iAlpha * 26)
If iAlpha > 0 Then
ConvertToLetter = Chr(iAlpha + 64)
If iRemainder > 0 Then
ConvertToLetter = ConvertToLetter & Chr(iRemainder + 64)
If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines