Sub ins_uti(sh)
s0 = "Report"
s1 = "Database"
rep_date = Sheets(s0).Cells(3, 5)
rep_type = Sheets(s0).Cells(4, 5)
date_report = Sheets(s0).Cells(5, 5)
Application.ScreenUpdating = False
Application.EnableEvents = False
With Sheets(s1).Range("A6").CurrentRegion
x = .Value
End With
For a = 6 To 60000
trd1 = Sheets(s1).Cells(a, 1)
db1 = Sheets(s1).Cells(a, 2)
ie1 = Sheets(s1).Cells(a, 3)
fam1 = Sheets(s1).Cells(a, 4)
grp1 = Sheets(s1).Cells(a, 5)
typ1 = Sheets(s1).Cells(a, 6)
stt1 = Sheets(s1).Cells(a, 7)
bsl1 = Sheets(s1).Cells(a, 8)
ctg1 = Sheets(s1).Cells(a, 10)
pli1 = Sheets(s1).Cells(a, 11)
dte1 = Sheets(s1).Cells(a, 12)
mat1 = Sheets(s1).Cells(a, 13)
ccy1 = Sheets(s1).Cells(a, 14)
nom1 = Sheets(s1).Cells(a, 15)
dea1 = Sheets(s1).Cells(a, 16)
tpo1 = Sheets(s1).Cells(a, 18)
cls1 = Sheets(s1).Cells(a, 20)
tnr1 = Sheets(s1).Cells(a, 22)
crf1 = Sheets(s1).Cells(a, 23)
mtm1_2 = Sheets(s1).Cells(a, 24) ' mtm in idr
mtm1 = Sheets(s1).Cells(a, 25) 'mtm ory ccy
add1_2 = Sheets(s1).Cells(a, 26) ' addon in idr
add1 = Sheets(s1).Cells(a, 27) 'uti ory
uti1_2 = Sheets(s1).Cells(a, 28) 'uti in idr
uti1 = Sheets(s1).Cells(a, 29) 'uti in ory
bnb1 = Sheets(s1).Cells(a, 30)
nom1_x = Sheets(s1).Cells(a, 31)
iss1 = Sheets(s1).Cells(a, 32)
nom1_2 = Sheets(s1).Cells(a, 33)
bis1 = Sheets(s1).Cells(a, 34)
flg1 = Sheets(s1).Cells(a, 35)
If iss1 = "USGOVT" Then
nom1_2 = Sheets(s1).Cells(a, 15)
End If
If trd1 = "" Then Exit For
Select Case sh
Case "1"
If db1 = "DFx" And bnb1 = "Y" Then
For b = 5 To 6000 'Sheets 3
tgl2 = Sheets(sh).Cells(b, 2)
ctg2 = Sheets(sh).Cells(b, 3)
lmt2 = Sheets(sh).Cells(b, 7)
ccy2 = Sheets(sh).Cells(b, 8)
uti2 = Sheets(sh).Cells(b, 9)
mtm2 = Sheets(sh).Cells(b, 14)
If ctg2 = ctg1 Then
lma = 0
nte = ""
uti3 = uti1_2 + uti2
mtm3 = mtm1_2 + mtm2
Sheets(sh).Cells(b, 9) = uti3
lma = lmt2 - uti3
Sheets(sh).Cells(b, 10) = lma
If lma < 0 Then nte = "Breach"
Sheets(sh).Cells(b, 12) = nte
If mtm1_2 < 0 Then
Sheets(sh).Cells(b, 14) = 0
End If
If mtm1_2 > 0 Or mtm1_2 = 0 Then
Sheets(sh).Cells(b, 14) = mtm3
End If
Exit For
End If
If ctg2 = "" Then
lma = 0
nte = ""
lmt2 = 0
uti3 = nom1_x + uti2
mtm3 = nom1_x + mtm2
Sheets(sh).Cells(b, 2) = rep_date
Sheets(sh).Cells(b, 3) = ctg1
Sheets(sh).Cells(b, 5) = "FX Bank"
Sheets(sh).Cells(b, 7) = lmt2
Sheets(sh).Cells(b, 8) = "IDR"
Sheets(sh).Cells(b, 9) = uti3
lma = lmt2 - uti3
Sheets(sh).Cells(b, 10) = lma
Sheets(sh).Cells(b, 11) = "0"
If lma < 0 Then nte = "Breach"
Sheets(sh).Cells(b, 12) = nte
If mtm3 < 0 Then
Sheets(sh).Cells(b, 14) = 0
End If
If mtm3 > 0 Or mtm3 = 0 Then
Sheets(sh).Cells(b, 14) = mtm3
End If
Exit For
End If
Next b
End If
Case "2"
If db1 = "DFx" And bnb1 = "N" Then
For b = 5 To 6000 'Sheets 4
tgl2 = Sheets(sh).Cells(b, 2)
ctg2 = Sheets(sh).Cells(b, 3)
lmt2 = Sheets(sh).Cells(b, 7)
ccy2 = Trim(Sheets(sh).Cells(b, 8))
uti2 = Sheets(sh).Cells(b, 9)
mtm2 = Sheets(sh).Cells(b, 14)
If ctg2 = ctg1 Then
lma = 0
nte = ""
uti3 = uti1_2 + uti2
mtm3 = mtm1_2 + mtm2
Sheets(sh).Cells(b, 9) = uti3
lma = lmt2 - uti3
Sheets(sh).Cells(b, 10) = lma
If lma < 0 Then nte = "Breach"
Sheets(sh).Cells(b, 12) = nte
If mtm3 < 0 Then
Sheets(sh).Cells(b, 14) = 0
End If
If mtm3 > 0 Or mtm3 = 0 Then
Sheets(sh).Cells(b, 14) = mtm3
End If
Exit For
End If
If ctg2 = "" Then
lma = 0
nte = ""
lmt2 = 0
uti3 = nom1_x + uti2
mtm3 = nom1_x + mtm2
Sheets(sh).Cells(b, 2) = rep_date
Sheets(sh).Cells(b, 3) = ctg1
Sheets(sh).Cells(b, 5) = "FX NonBank"
Sheets(sh).Cells(b, 7) = lmt2
Sheets(sh).Cells(b, 8) = "IDR"
Sheets(sh).Cells(b, 9) = uti3
lma = lmt2 - uti3
Sheets(sh).Cells(b, 10) = lma
Sheets(sh).Cells(b, 11) = "0"
If lma < 0 Then nte = "Breach"
Sheets(sh).Cells(b, 12) = nte
If mtm3 < 0 Then
Sheets(sh).Cells(b, 14) = 0
End If
If mtm3 > 0 Or mtm3 = 0 Then
Sheets(sh).Cells(b, 14) = mtm3
End If
Exit For
End If
Next b
End If
End Select
Next a
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
macro ins_convert:
Sub ins_convert(sh)
s1 = "S1"
Application.ScreenUpdating = False
Application.EnableEvents = False
For a = 5 To 6000
tgl1 = Sheets(sh).Cells(a, 2)
lim1 = Sheets(sh).Cells(a, 7)
ccy1 = Sheets(sh).Cells(a, 8)
uti1 = Sheets(sh).Cells(a, 9)
nte1 = Sheets(sh).Cells(a, 12)
mtm1 = Sheets(sh).Cells(a, 14)
If tgl1 = "" Then Exit For
Select Case sh
Case "4"
If ccy1 = "USD" Then
ccy1 = ccy1 + "-IDR"
For b = 6 To 6000
ccy2 = Sheets(s1).Cells(b, 7)
prc2 = Sheets(s1).Cells(b, 8)
prc3 = Sheets(s1).Cells(b, 11)
If ccy2 = "" Then Exit For
If ccy2 = ccy1 Then
nte = ""
uti3 = uti1 / prc2
mtm3 = mtm1 / prc3
Sheets(sh).Cells(a, 9) = uti3
lma = lim1 - uti3
Sheets(sh).Cells(a, 10) = lma
If lma < 0 Then nte = "Breach"
Sheets(sh).Cells(a, 12) = nte
Sheets(sh).Cells(a, 14) = mtm3
Exit For
End If
Next b
ElseIf ccy1 = "EUR" Then
ccy1 = ccy1 + "-IDR"
For b = 6 To 6000
ccy2 = Sheets(s1).Cells(b, 7)
prc2 = Sheets(s1).Cells(b, 8)
prc3 = Sheets(s1).Cells(b, 11)
If ccy2 = "" Then Exit For
If ccy2 = ccy1 Then
nte = ""
uti3 = uti1 / prc2
mtm3 = mtm1 / prc3
Sheets(sh).Cells(a, 9) = uti3
lma = lim1 - uti3
Sheets(sh).Cells(a, 10) = lma
If lma < 0 Then
nte = "Breach"
End If
If lma > 0 Then
nte = ""
End If
Sheets(sh).Cells(a, 12) = nte
Sheets(sh).Cells(a, 14) = mtm3
Exit For
End If
Next b
End If
End Select
Next a
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Bookmarks