View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Martin Fishlock Martin Fishlock is offline
external usenet poster
 
Posts: 694
Default Importing signed over-punch text into Excel

Alex,

AFAIK Excel does not have any capability to import overpunched numbers.
Therefore you need to convert them.

One option is to use the following function. The parameters szCode is the
overpunched number and iRadix is the number of decimals.


Option Explicit

Function overpunch(szCode As String, iRadix As Integer) As Double

Dim ans As Double
Dim r As String

Application.Volatile
szCode = UCase(Trim(szCode))
ans = 10 * CDbl(Left(szCode, Len(szCode) - 1))
r = Right(szCode, 1)
Select Case r
Case "A" To "I" ' +ve sign 1..9
ans = ans + Asc(r) - Asc("A") + 1
Case "{" ' +ve sign 0
' no action
Case "J" To "R" ' -ve sign 1..9
ans = -(ans + Asc(r) - Asc("J") + 1)
Case "}" ' -ve sign 0
ans = -ans
Case "0" To "9" ' unsigned
' no action
End Select
overpunch = ans / (10 ^ iRadix)
End Function
--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Alex" wrote:

Does anyone know how to import and convert a signed over-punch text into
Excel? I received a text file and its format includes signed over-punch
chaharacters, e.g. 0025{ = 2.50, also how do I tell Excel about implied
decimal. It can be either part of a vba language or function link for
convertion, preferably both.

Thank you in advance.