LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default adding a code to a cell?

Just in case anyone was interested. I did manage to solve my issue via a
macro.

All the data I wanted to code is in column A, and is a ll $ values.
Therefore I can multiple by 100 to get an integer value to apply mode code
too.

__________

Sub Code()

Application.ScreenUpdating = False
Cells(1, 1).Select

Do While Not IsEmpty(ActiveCell)

CellNum = ActiveCell.Value
CellLength = Len(CellNum)
CellVal = Empty

If IsNumeric(CellNum) Then
CellNum = CellNum * 100
Else
Application.ScreenUpdating = True
Err = MsgBox(" Non numeric value in cell?", vbOKCancel)
If Err = vbCancel Then End
End If

Application.ScreenUpdating = False
For i = 1 To CellLength
If Mid(CellNum, i, 1) = 1 Then CellVal = CellVal & "A"
If Mid(CellNum, i, 1) = 2 Then CellVal = CellVal & "B"
If Mid(CellNum, i, 1) = 3 Then CellVal = CellVal & "C"
If Mid(CellNum, i, 1) = 4 Then CellVal = CellVal & "D"
If Mid(CellNum, i, 1) = 5 Then CellVal = CellVal & "E"
If Mid(CellNum, i, 1) = 6 Then CellVal = CellVal & "F"
If Mid(CellNum, i, 1) = 7 Then CellVal = CellVal & "G"
If Mid(CellNum, i, 1) = 8 Then CellVal = CellVal & "H"
If Mid(CellNum, i, 1) = 9 Then CellVal = CellVal & "I"
If Mid(CellNum, i, 1) = 0 Then CellVal = CellVal & "Z"
Next

ActiveCell.Offset(0, 1).Value = CellVal
ActiveCell.Offset(1, 0).Select

Loop
Application.ScreenUpdating = True
End Sub

________________________

BC



"Brad" wrote in message news:...
Hi Harold,

That was my first instinct. However I'm pretty green when it comes to
Vlookup's so some help would be appreciated.

Initially my table on sheet 2 looked like...

colA | colB

1 | A

2 | B

3 | C

4 | D

5 | E

6 | F

7 | G

8 | H

9 | I

0 | Z

How do I then do a Vlookup to produce the desired result? Bearing in mind,
the numbers I want to code in column A (coded letters in column B) on
sheet 1 are not necessarily uniform, or logical. Cell A1 could have
"97.95", "129.77" or another equally random combination.

TIA for any help.

BC

"Harald Staff" wrote in message
...
Hi BC

Put all corresponding logic in a table and a VLOOKUP formula in Cell B1.
See
Help on VLOOKUP.

HTH. Best wishes Harald

"Brad" skrev i melding
...
H alli,

I'm trying to devise a way to do the following...

Cell A1 has "12.34" in it. I would like B1 to show "ABCD"
Cell A2 has "123.45" in it. I would like B2 to show "ABCDE"
Cell A3 has "12.50" in it. I would like B3 to show "ABEZ"

Any thoughts on how to achieve this either through VBA or a cell
formula?

TIA.
BC








 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding an autoshape to vba code NG Excel Discussion (Misc queries) 0 October 19th 09 07:44 PM
adding a code to a cell? Brad[_22_] Excel Programming 2 April 4th 06 10:49 PM
Adding a folder with code Tyrell Excel Programming 3 March 3rd 06 06:43 PM
Adding space to VBA code John Excel Programming 1 June 28th 04 08:56 PM
Adding code to worksheets mgs[_2_] Excel Programming 0 January 4th 04 11:33 PM


All times are GMT +1. The time now is 08:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"