Convert Numbers into Text?

robgolf

New Member
Joined
Mar 29, 2012
Messages
9
I would like to take all numbers in column C of my spreadsheet and turn them into text based on the text value I gave each number.

Ex: I would type the number "1" into cell C1 and excel would automatically convert it into the word "New York". If I typed "2" into a cell it would convert in into the text "Chicago".

Thanks so much guys, any help is greatly appreciated!

-Rob
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
I would like to take all numbers in column C of my spreadsheet and turn them into text based on the text value I gave each number.

Ex: I would type the number "1" into cell C1 and excel would automatically convert it into the word "New York". If I typed "2" into a cell it would convert in into the text "Chicago".

Thanks so much guys, any help is greatly appreciated!

-Rob
See if this helps:

http://contextures.com/xlFunctions02.html
 
Upvote 0
If that's the only 2, put this into the worksheet module:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$C$1" Then
        If Target = 1 Then Target = "New York"
        If Target = 2 Then Target = "Chicago"
    End If
End Sub
 
Upvote 0
If that's the only 2, put this into the worksheet module:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$C$1" Then
        If Target = 1 Then Target = "New York"
        If Target = 2 Then Target = "Chicago"
    End If
End Sub

After I open up the VBA editor should I go to insert module, paste that code in and then hit save? I tried that and it did not work. I am new to VBA so I would need further guidance. Thanks so much!
 
Upvote 0
Change

Code:
If Target.Address = "$C$1" Then

to

Code:
If Target.Column = 3 Then

or to this

Code:
If Not Intersect(Target, Range("C:C")) Is Nothing Then

That should work anywhere in Column C

HTH
 
Upvote 0
Change

Code:
If Target.Address = "$C$1" Then

to

Code:
If Target.Column = 3 Then

or to this

Code:
If Not Intersect(Target, Range("C:C")) Is Nothing Then

That should work anywhere in Column C

HTH

OK GREAT! That line of code worked for all of column C.

The issue now lies in the fact that I have two "Worksheet Change" items in the same line of code and it causes and it says "Ambiguous name detected" when I try to write something in column C.

Here is my code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
If Target = 1 Then Target = "New York"
If Target = 2 Then Target = "Chicago"
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
With Cell
If .Column = Range("C:C").Column Then
Cells(.Row, "D").Value = Now()
End If
End With
Next Cell
End Sub

Any thoughts on how I can have two separate worksheet changes without causing an error?

Last Question: If I wanted to take a letter such as "L" and have it automatically convert to a word such as "Apple" for all of Column C how would one go about doing that? I tried using the code you supplied me with above but I think that only works for numbers when declaring a target.

Thanks again!
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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