The following function looks for the text "VALUE" and then extracts the numbers in the text that follow it. Examples:
Bonds
FEDERAL NAT'L MTGE ASSN 25,000 PAR VALUE DTD 10/1/1999 8.5000% 11/15/2013 TAXPAYER ID: 04-2222222 SSB-TRUST CUSTODY DISTRIBUTION VALUE: 8,529.44 STATE STREET A/C #BL3625, FAMILY SERVICE OF ....
Stocks
SYMANTEC CORP COM 1,800 SHARES TAXPAYER ID: 04-2222222 SSB-TRUST CUSTODY DISTRIBUTION VALUE: 135,630.00 STATE STREET A/C #xx9999, FAMILY SERVICE ...
Stock Gifts
INTEL CORP COM 322 SHARES TO BRAD H. CLIENT TAXPAYER ID: 111-11-1111 MADE JANUARY 16, 2002 AT VALUE $10,991.47
Reversed Transaction
XXXXXXXX MTGE LOAN TRUST-SER 1997-1 25,000 PAR VALUE DTD 4/15/1999 7.3500% 5/25/2027 TAXPAYER ID: 04-2222222 REVERSED ENTRY POSTED ON 01/18/2002
Public Function GetValue(ExplText)
Dim Step1 As Integer, Step2 As Integer, Step3 As String, step4 As Integer, step5 As String, MyString As String, MyStringLength As Integer
MyString = "VALUE"
MyStringLength = Len(MyString) + 2 '# characters, plus 2, to get to number
Step1 = WorksheetFunction.Find(MyString, ExplText) 'find position of VALUE in string
Step2 = Step1 + MyStringLength 'take position in step 1 for start of VALUE and add 2 (# characters, plus 2, to get to number)
Step3 = Mid(ExplText, Step2, 255) 'starts from specified character(step2) and goes on for 255 characters
step4 = WorksheetFunction.Find(".", Step3) + 2 'finds decimal and adds 2 to get decimal places
step5 = Left(Step3, step4) 'takes step3 string and provides left # of characters as determined in step 4
GetValue = step5 * 1 'take string from left function and multiply by one to get number
End Function
I want to use the same function for the three types of transactions listed above, to get bond values, stock values, and stock gift values.
I am encountering three problems:
1) the text "PAR VALUE" for bonds preceeds "DISTRIBUTION VALUE"
2) gift values do not read "DISTRIBUTION VALUE" but just "VALUE"
3) if a transaction is reversed, I want to return a value of 0
I could ask our Securities Dept. for consistency in the data entry so that I always had a text string of "DISTRIBUTION VALUE" and not "VALUE", but how do I get around the reversals so that I get a 0 value?
I need to calculate the value of multiple transactions. Any help is very much appreciated.
Bonds
FEDERAL NAT'L MTGE ASSN 25,000 PAR VALUE DTD 10/1/1999 8.5000% 11/15/2013 TAXPAYER ID: 04-2222222 SSB-TRUST CUSTODY DISTRIBUTION VALUE: 8,529.44 STATE STREET A/C #BL3625, FAMILY SERVICE OF ....
Stocks
SYMANTEC CORP COM 1,800 SHARES TAXPAYER ID: 04-2222222 SSB-TRUST CUSTODY DISTRIBUTION VALUE: 135,630.00 STATE STREET A/C #xx9999, FAMILY SERVICE ...
Stock Gifts
INTEL CORP COM 322 SHARES TO BRAD H. CLIENT TAXPAYER ID: 111-11-1111 MADE JANUARY 16, 2002 AT VALUE $10,991.47
Reversed Transaction
XXXXXXXX MTGE LOAN TRUST-SER 1997-1 25,000 PAR VALUE DTD 4/15/1999 7.3500% 5/25/2027 TAXPAYER ID: 04-2222222 REVERSED ENTRY POSTED ON 01/18/2002
Public Function GetValue(ExplText)
Dim Step1 As Integer, Step2 As Integer, Step3 As String, step4 As Integer, step5 As String, MyString As String, MyStringLength As Integer
MyString = "VALUE"
MyStringLength = Len(MyString) + 2 '# characters, plus 2, to get to number
Step1 = WorksheetFunction.Find(MyString, ExplText) 'find position of VALUE in string
Step2 = Step1 + MyStringLength 'take position in step 1 for start of VALUE and add 2 (# characters, plus 2, to get to number)
Step3 = Mid(ExplText, Step2, 255) 'starts from specified character(step2) and goes on for 255 characters
step4 = WorksheetFunction.Find(".", Step3) + 2 'finds decimal and adds 2 to get decimal places
step5 = Left(Step3, step4) 'takes step3 string and provides left # of characters as determined in step 4
GetValue = step5 * 1 'take string from left function and multiply by one to get number
End Function
I want to use the same function for the three types of transactions listed above, to get bond values, stock values, and stock gift values.
I am encountering three problems:
1) the text "PAR VALUE" for bonds preceeds "DISTRIBUTION VALUE"
2) gift values do not read "DISTRIBUTION VALUE" but just "VALUE"
3) if a transaction is reversed, I want to return a value of 0
I could ask our Securities Dept. for consistency in the data entry so that I always had a text string of "DISTRIBUTION VALUE" and not "VALUE", but how do I get around the reversals so that I get a 0 value?
I need to calculate the value of multiple transactions. Any help is very much appreciated.