What's wrong with this code?

DetroitDavid

Board Regular
Joined
Jul 20, 2013
Messages
211
Nubie here, trying to do something and it's not working, help is appreciated!

On my sheet, E1 is a header. E2 to Ex (end of data) will have a single digit number 1-12 which I need to convert to a corresponding letter of the alphabet, A-L (1=A, 2=B, 3=C and so on).

So if a 6 (currently formatted General) is shown in E2 (no extra spaces), I'm trying to populate it and all the cells of data in that column with the letter F.

I could also use fill down or replace, whatever works best, I'm just missing something in the loop, case statement or syntax.

TIA-DAH
 
Last edited:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Welcome to MrExcel.

What's your code that's causing a problem? To convert a number in a cell to a letter you can use eg:

Range("A1").Value = Chr(Range("A1").Value + 64)
 
Upvote 0
Thank you for the welcome!

Maybe what I need is help with the syntax of looping and writing.

CODE

Dim cell As Range, Rowz As Long
Rowz = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

For Each cell In Range("E2:E" & Rowz)
Range("E2").Value = Chr(Range("E2").Value + 64)
Next

E1: Label
E2: Change # to Char (6 becomes cap F)
E3: Change # to Char (6 becomes cap F)
E4: Change # to Char (6 becomes cap F)
E5: Change # to Char (6 becomes cap F)
E6: Change # to Char (6 becomes cap F)
E7: Change # to Char (6 becomes cap F)
E8: Change # to Char (6 becomes cap F)
E9: Change # to Char (6 becomes cap F)
x... x... x...
E35: Change # to Char (6 becomes cap F)
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top