Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Moideen wrote:
We are Maintaining cost in English Letters, Kindly Help to get COST on Coloumn2 Examples, A : 1 B : 2 C : 3 D : 4 F : 5 If I Entered 242 on Coloumn1 Need Automatic Shown BDB on Coloumn2 Put this in the sheet's object in the VBA editor: Private Sub Worksheet_Change(ByVal Target As Range) Dim cell As Range, outP As String, costs As Variant costs = Array("#", "A", "B", "C", "D", "F", "#", "#", "#", "#") For Each cell In Target If cell.Column = 1 Then outP = "" c = Abs(Val(cell.Value)) Do While c 0 n = c Mod 10 c = c \ 10 outP = costs(n) & outP Loop Me.Cells(cell.Row, cell.Column + 1).Value = outP End If Next End Sub Edit the 'costs' array to fit. (The hashes are there to indicate data entry errors. If you don't want them, don't delete them -- change them to "".) If this is meant to apply to the entire workbook, put this in the ThisWorkbook object instead: Private Sub Workbook_SheetChange(ByVal Sh As Object, _ ByVal Target As Range) Dim cell As Range, outP As String, costs As Variant costs = Array("#", "A", "B", "C", "D", "F", "#", "#", "#", "#") For Each cell In Target If cell.Column = 1 Then outP = "" c = Abs(Val(cell.Value)) Do While c 0 n = c Mod 10 c = c \ 10 outP = costs(n) & outP Loop Sh.Cells(cell.Row, cell.Column + 1).Value = outP End If Next End Sub -- Money and faith are powerful motivators. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Auto alphabetic | Excel Worksheet Functions | |||
HIghest Value - Numeric and Alphabetic | Excel Worksheet Functions | |||
how can I set up an alphabetic sequence? | Excel Discussion (Misc queries) | |||
Alphabetic autofill | Excel Discussion (Misc queries) | |||
alphabetic order | Excel Programming |