I have a Cell with a String like this
(H/Y): As per un-audited half yearly accounts as on 30.06.2014 (Jan'14 to June'14), the Company has reported consolidated net profit after tax (excluding non-controlling interests) of **Tk. 5.87** million with consolidated EPS of **Tk. 0.05** as against **Tk. 33.46** million and **Tk. 0.31** respectively for the same period of the previous year. Whereas consolidated net profit after tax (excluding non-controlling interests) was **Tk. 2.71** million with consolidated EPS of **Tk. 0.02** for the period of 3 months (Apr'14 to June'14) ended on 30.06.2014 as against **Tk. 7.42** million and **Tk. 0.07** respectively for the same period of the previous year.
I want to Find, Currency Convert and Replace all Tk. 5.87, Tk. 0.05, etc.
I already can do this using the following excel formulas.
=REPLACE(A1,FIND(" Tk. ",A1,1)+5,FIND(" ",A1,FIND(" Tk. ",A1,1)+5)-(FIND(" Tk. ",A1,1)+5),(MID(A1,FIND(" Tk. ",A1,1)+5, FIND(" ", A1,FIND(" Tk. ",A1,1)+5)-(FIND(" Tk. ",A1,1)+5)))/B1)
=REPLACE(C1,FIND(" Tk. ",A1,1), FIND(" ", A1,FIND(" Tk. ",A1,1)+5)-(FIND(" Tk. ",A1,1)+5)," USD")
and the result is (Note that only this first one is converted)
(H/Y): As per un-audited half yearly accounts as on 30.06.2014 (Jan'14 to June'14), the Company has reported consolidated net profit after tax (excluding non-controlling interests) of USD 0.073375 million with consolidated EPS of Tk. 0.05 as against Tk. 33.46 million and Tk. 0.31 respectively for the same period of the previous year. Whereas consolidated net profit after tax (excluding non-controlling interests) was Tk. 2.71 million with consolidated EPS of Tk. 0.02 for the period of 3 months (Apr'14 to June'14) ended on 30.06.2014 as against Tk. 7.42 million and Tk. 0.07 respectively for the same period of the previous year.
But instead of using the Excel formula i would like to do this on VBA Converting all Currency in a workbook sheet.
This is what i Have Done SO far
Sub Curr_Convert()
Dim count As Single
Dim No_of_Char As Double
Dim Val_2_Cnvrt As Double
Dim Val_aftr_Cnvrt As Double
Dim Uncnvrtd_Strng As String
Dim cnvrtd_Strng As String
Dim cnvrtd_Strng2 As String
Dim Cnvrtin_Rate As Single
Cnvrtin_Rate = 80
count = 0
Uncnvrtd_Strng = Range("A1")
Do While count < 10
No_of_Char = (InStr((InStr(1, Uncnvrtd_Strng, "Tk. ") + 4), Uncnvrtd_Strng, " ")) - (InStr(1, Uncnvrtd_Strng, "Tk. ") + 4)
Val_2_Cnvrt = Mid(Uncnvrtd_Strng, (InStr(1, Uncnvrtd_Strng, "Tk. ") + 4), No_of_Char)
Val_aftr_Cnvrt = Val_2_Cnvrt / Cnvrtin_Rate
Range("A7").Value = Val_aftr_Cnvrt
cnvrtd_Strng = Replace(Range("A1"), Val_2_Cnvrt, Val_aftr_Cnvrt)
cnvrtd_Strng2 = Replace(cnvrtd_Strng, "Tk. ", "USD ", 1, 1)
Uncnvrtd_Strng = cnvrtd_Strng2
count = count + 1
Loop
Range("A8").Value = cnvrtd_Strng2
End Sub
Any Help is appreciated. Thanks in advance.