0

I am very new to VBA and i am having a hard time with this issue : i have a column with number up to 15 that i need to convert to letters, checking the forum i found a fonction N2L fonction, but i need it to do it from VBA becaue others cells formulas relie on this column input so i can't use char etc... I did a newbie code that works but it is very very ugly. Could you guys give a me hand, all help would be me much appreciated. Here is what i did.

For Each cellule In Range("D24:D58")
Select Case (cellule)
    Case Is = 1
cellule.Value = "A"
End Select
Next cellule

For Each cellule In Range("D24:D58")
Select Case (cellule)
    Case Is = 2
cellule.Value = "B"
End Select
Next cellule

For Each cellule In Range("D24:D58")
Select Case (cellule)
    Case Is = 3
cellule.Value = "C"
End Select
Next cellule

and so on until 15 ... (I have declared cellule as range at the beginning of the sub) Thanks very much in advance.

Warcupine
  • 4,460
  • 3
  • 15
  • 24
  • 2
    Could it go beyond 26? It gets a lot more complicated when you move to double letters. – Warcupine Jan 05 '22 at 15:12
  • 1
    Rather than finding the column letter just use [Cells](https://learn.microsoft.com/en-us/office/vba/api/excel.worksheet.cells). `Cells(2,1)` is A2, `Range(cells(2,1),Cells(3,4))` is A2:D3. Not sure what your actual case is, but easier to leave the number as a number. – Darren Bartrup-Cook Jan 05 '22 at 15:23
  • Was going to post an answer.... but as @BigBen pointed out there's already an answer. I'd use the one given by ashleedawg (or any that use SPLIT). – Darren Bartrup-Cook Jan 05 '22 at 15:36
  • Thank you so much for you feedback. In my case i just need 1 to 26 no need to go beyond. And to be clear this is not related to column this is for accounting i have number in one column that need to be associated with their number. 1=A,2=B,C=3 and so on. – David Deval Jan 05 '22 at 15:50

0 Answers0