View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson Greg Wilson is offline
external usenet poster
 
Posts: 747
Default Price List For Sales Representative

Quick and dirty with minimal testing:-

Const code As String = "MAKEPROFIT"

Sub TestConvertToCode()
'Converts number to code
With ActiveCell
.Value = ConvertToCode(.Value)
End With
End Sub

Sub TestConvertToNum()
'Converts code back to number
With ActiveCell
.Value = ConvertToNum(.Value)
End With
End Sub

Function ConvertToCode(Val As Single) As String
Dim i As Integer
Dim t As String, tt As String, v As String

v = Format(Val, "#.00")
For i = 1 To Len(v)
t = Mid(v, i, 1)
Select Case t
Case 0
tt = tt & "T"
Case "."
tt = tt & t
Case Else
tt = tt & Mid(code, CInt(t), 1)
End Select
Next
ConvertToCode = tt
End Function

Function ConvertToNum(txt As String) As String
Dim i As Integer, n As Integer
Dim t As String, tt As String

For i = 1 To Len(txt)
t = Mid(txt, i, 1)
Select Case t
Case "T"
n = 0
tt = tt & n
Case "."
tt = tt & t
Case Else
n = InStr(code, t)
tt = tt & n
End Select
Next
ConvertToNum = Format(tt, "#.00")
End Function

Regards,
Greg

" wrote:

Hello, I need help!

I am trying to do a price list for my representatives where we have our
retail prices and also I would like to have a price code for my bottom
line price.

The code should have the words MAKEPROFIT as the key for 1234567890

therefore a price $11.33 should display MM.KK or $44.77 should display
EE.OO

could anybody help with this issue?

Thank you,

Claudio