update,
This commit is contained in:
BIN
task2/Copy and Paste.xlsm
Normal file
BIN
task2/Copy and Paste.xlsm
Normal file
Binary file not shown.
BIN
task2/d7a3b2ca-8184-4874-8f1b-21e77189936a_progressive.jpg
(Stored with Git LFS)
Normal file
BIN
task2/d7a3b2ca-8184-4874-8f1b-21e77189936a_progressive.jpg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
task2/draft1/Copy and Paste_draft.xlsm
Normal file
BIN
task2/draft1/Copy and Paste_draft.xlsm
Normal file
Binary file not shown.
454
task2/draft1/ThisWorkbook.cls
Normal file
454
task2/draft1/ThisWorkbook.cls
Normal file
@@ -0,0 +1,454 @@
|
||||
' change log:
|
||||
|
||||
Option explicit
|
||||
|
||||
Dim first_row As Integer
|
||||
Dim current_row As Integer
|
||||
Dim last_check_row As Integer
|
||||
|
||||
Dim ADJUSTMENT_WORKSHEET as string
|
||||
Dim BMF_ADJUSTMENT_WORKSHEET as string
|
||||
|
||||
' BALANCE_SHEET
|
||||
Dim COL_BALANCE_SHEET_NA_1 as string
|
||||
Dim COL_BALANCE_SHEET_PCCO_1 as string
|
||||
Dim COL_BALANCE_SHEET_AMOUNT_TO_ADJ_1 as string
|
||||
|
||||
Dim COL_BALANCE_SHEET_NA_2 as string
|
||||
Dim COL_BALANCE_SHEET_PCCO_2 as string
|
||||
Dim COL_BALANCE_SHEET_AMOUNT_TO_ADJ_2 as string
|
||||
|
||||
' OFF_BALANCE_SHEET
|
||||
Dim COL_OFF_BALANCE_SHEET_NA_1 as string
|
||||
Dim COL_OFF_BALANCE_SHEET_PCCO_1 as string
|
||||
Dim COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_1 as string
|
||||
|
||||
Dim COL_OFF_BALANCE_SHEET_NA_2 as string
|
||||
Dim COL_OFF_BALANCE_SHEET_PCCO_2 as string
|
||||
Dim COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_2 as string
|
||||
|
||||
Dim COL_FINAL_BMF_ID as string
|
||||
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_LINE_TYPE as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_ADJUSTMENT_ID as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_ADJUSTMENT_TYPE as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_COMMENT as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_REPORTING_ENTITY as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_PCCO as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_PCEC as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_ACCOUNTING_BALANCE_CURRENCY as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_FAIR_VALUE as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_ECONOMIC_AGENT as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_OPAQUE_REPORTING_ENTITY as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_REMAINING_MATURITY as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_IFRS13 as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_COUNTRY as string
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_LOCAL_OPERATIONAL_ACCOUNT as string
|
||||
|
||||
|
||||
Sub init()
|
||||
On Error GoTo eh
|
||||
|
||||
' HEADER_ROW = 6
|
||||
first_row = 6
|
||||
current_row = first_row
|
||||
last_check_row = 9999
|
||||
|
||||
' ADJUSTMENT_SHEET
|
||||
ADJUSTMENT_WORKSHEET = "Adjustment"
|
||||
|
||||
' BALANCE_SHEET
|
||||
COL_BALANCE_SHEET_NA_1 = "Q"
|
||||
COL_BALANCE_SHEET_PCCO_1 = "R"
|
||||
COL_BALANCE_SHEET_AMOUNT_TO_ADJ_1 = "S"
|
||||
|
||||
COL_BALANCE_SHEET_NA_2 = "T"
|
||||
COL_BALANCE_SHEET_PCCO_2 = "U"
|
||||
COL_BALANCE_SHEET_AMOUNT_TO_ADJ_2 = "V"
|
||||
|
||||
' OFF_BALANCE_SHEET
|
||||
COL_OFF_BALANCE_SHEET_NA_1 = "X"
|
||||
COL_OFF_BALANCE_SHEET_PCCO_1 = "Y"
|
||||
COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_1 = "Z"
|
||||
|
||||
COL_OFF_BALANCE_SHEET_NA_2 = "AA"
|
||||
COL_OFF_BALANCE_SHEET_PCCO_2 = "AB"
|
||||
COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_2 = "AC"
|
||||
|
||||
COL_FINAL_BMF_ID = "AI"
|
||||
|
||||
' BMF_ADJUSTMENT_SHEET
|
||||
BMF_ADJUSTMENT_WORKSHEET = "BMF Adjustment result"
|
||||
COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID = "A"
|
||||
COL_BMF_ADJUSTMENT_SHEET_LINE_TYPE = "B"
|
||||
COL_BMF_ADJUSTMENT_SHEET_ADJUSTMENT_ID = "C"
|
||||
COL_BMF_ADJUSTMENT_SHEET_ADJUSTMENT_TYPE = "D"
|
||||
COL_BMF_ADJUSTMENT_SHEET_COMMENT = "E"
|
||||
COL_BMF_ADJUSTMENT_SHEET_REPORTING_ENTITY = "F"
|
||||
COL_BMF_ADJUSTMENT_SHEET_PCCO = "G"
|
||||
COL_BMF_ADJUSTMENT_SHEET_PCEC = "H"
|
||||
COL_BMF_ADJUSTMENT_SHEET_ACCOUNTING_BALANCE_CURRENCY = "I"
|
||||
COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE = "J"
|
||||
COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT = "K"
|
||||
COL_BMF_ADJUSTMENT_SHEET_FAIR_VALUE = "BH"
|
||||
COL_BMF_ADJUSTMENT_SHEET_ECONOMIC_AGENT = "BI"
|
||||
COL_BMF_ADJUSTMENT_SHEET_OPAQUE_REPORTING_ENTITY = "BJ"
|
||||
COL_BMF_ADJUSTMENT_SHEET_REMAINING_MATURITY = "BK"
|
||||
COL_BMF_ADJUSTMENT_SHEET_IFRS13 = "BL"
|
||||
COL_BMF_ADJUSTMENT_SHEET_COUNTRY = "BM"
|
||||
COL_BMF_ADJUSTMENT_SHEET_LOCAL_OPERATIONAL_ACCOUNT = "BN"
|
||||
|
||||
Done:
|
||||
Exit Sub
|
||||
|
||||
eh:
|
||||
Debug.Print "init:Error: " & Err.Description
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Function CheckIfBalanceSheetAmountToAdjust2IsZero(current_row As Integer)
|
||||
On Error GoTo eh
|
||||
Dim output as boolean
|
||||
output = false
|
||||
Dim temp as string
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_AMOUNT_TO_ADJ_2 & CStr(current_row)).Value
|
||||
|
||||
if (temp = "0") then
|
||||
output = true
|
||||
end if
|
||||
|
||||
CheckIfBalanceSheetAmountToAdjust2IsZero = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfBalanceSheetAmountToAdjust2IsZero:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Function CheckIfBalanceSheetNa2Exist(current_row As Integer)
|
||||
On Error GoTo eh
|
||||
Dim output as boolean
|
||||
output = false
|
||||
Dim temp as string
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_NA_2 & CStr(current_row)).Value
|
||||
|
||||
if (temp <> "") then
|
||||
output = true
|
||||
end if
|
||||
|
||||
CheckIfBalanceSheetNa2Exist = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfBalanceSheetNa2Exist:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function CheckIfBalanceSheetPcco2Exist(current_row As Integer)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim output as boolean
|
||||
output = false
|
||||
Dim temp as string
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_PCCO_2 & CStr(current_row)).Value
|
||||
|
||||
if (temp <> "") then
|
||||
output = true
|
||||
end if
|
||||
|
||||
CheckIfBalanceSheetPcco2Exist = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfBalanceSheetPcco2Exist:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function CheckIfBalanceSheetAmountToAdjust2Exist(current_row As Integer)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim output as boolean
|
||||
output = false
|
||||
Dim temp as string
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_AMOUNT_TO_ADJ_2 & CStr(current_row)).Value
|
||||
|
||||
if (temp <> "") then
|
||||
output = true
|
||||
end if
|
||||
|
||||
CheckIfBalanceSheetAmountToAdjust2Exist = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfBalanceSheetAmountToAdjust2Exist:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function isCurrentRowNeedToProcess(input_row As Integer)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim output As Boolean
|
||||
Dim cell_value As Currency
|
||||
Dim input_cell As String
|
||||
input_cell = GRANDTOTAL_COL & input_row
|
||||
|
||||
Done:
|
||||
isCurrentRowNeedToProcess = Not (IsEmpty(Worksheets(ADJUSTMENT_WORKSHEET).Range(input_cell).Value))
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "isCurrentRowNeedToProcess:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function getLastCheckRow(first_row As Integer)
|
||||
On Error GoTo eh
|
||||
getLastCheckRow = first_row + 10
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "getLastCheckRow:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
function checkAdjustmentSheetLastRow(current_row as integer)
|
||||
On Error GoTo eh
|
||||
Dim output as boolean
|
||||
output = True
|
||||
|
||||
dim j as integer
|
||||
Dim temp as string
|
||||
|
||||
For j = current_row to getLastCheckRow(current_row)
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_FINAL_BMF_ID & CStr(current_row)).Value
|
||||
if (temp <> "") then
|
||||
output = False
|
||||
end if
|
||||
next j
|
||||
|
||||
checkAdjustmentSheetLastRow = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "checkAdjustmentSheetLastRow:Error: " & Err.Description
|
||||
|
||||
end function
|
||||
|
||||
function checkBmfAdjustmentSheetLastRow(current_row as integer)
|
||||
On Error GoTo eh
|
||||
Dim output as boolean
|
||||
output = True
|
||||
|
||||
dim j as integer
|
||||
Dim temp as string
|
||||
|
||||
For j = current_row to getLastCheckRow(current_row)
|
||||
temp = Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(current_row)).Value
|
||||
if (temp <> "") then
|
||||
output = False
|
||||
end if
|
||||
next j
|
||||
|
||||
checkBmfAdjustmentSheetLastRow = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "checkBmfAdjustmentSheetLastRow:Error: " & Err.Description
|
||||
|
||||
end function
|
||||
|
||||
Function checkIfAlreadyExistInBmfAdjustmentResult(adj_bmf_id as string, adj_pcco as string)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim i as integer
|
||||
Dim bmf_adjustment_sheet_last_row as integer
|
||||
Dim found as boolean
|
||||
found = false
|
||||
Dim temp_value as string
|
||||
Dim bmf_adj_bmf_id as string
|
||||
Dim bmf_adj_pcco as string
|
||||
|
||||
bmf_adjustment_sheet_last_row = getBMFAdjustmentResultListEnd(1)
|
||||
|
||||
For i = 1 to bmf_adjustment_sheet_last_row
|
||||
bmf_adj_bmf_id = Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(i)).Value
|
||||
bmf_adj_pcco = Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_PCCO & CStr(i)).Value
|
||||
debug.print adj_bmf_id
|
||||
debug.print adj_pcco
|
||||
if (bmf_adj_bmf_id = adj_bmf_id and bmf_adj_pcco = adj_pcco ) then
|
||||
found = true
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(i)).Interior.Color = rgb(214, 48, 49)
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_PCCO & CStr(i)).Interior.Color = rgb(214, 48, 49)
|
||||
exit for
|
||||
end if
|
||||
next i
|
||||
|
||||
checkIfAlreadyExistInBmfAdjustmentResult = found
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "checkIfAlreadyExistInBmfAdjustmentResult:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function getBMFAdjustmentResultListEnd(start_row as integer)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim i as integer
|
||||
|
||||
Dim last_row as boolean
|
||||
Dim last_row_found as boolean
|
||||
last_row_found = false
|
||||
last_row = True
|
||||
current_row = start_row
|
||||
|
||||
For i = start_row To 9999
|
||||
current_row = i
|
||||
last_row_found = checkBmfAdjustmentSheetLastRow(current_row)
|
||||
|
||||
if (last_row_found = true) then
|
||||
exit for
|
||||
end if
|
||||
Next i
|
||||
|
||||
getBMFAdjustmentResultListEnd = current_row -1
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "getBMFAdjustmentResultListEnd:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function getAdjustmentSheetListEnd(start_row as integer)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim i as integer
|
||||
|
||||
Dim last_row as boolean
|
||||
Dim last_row_found as boolean
|
||||
last_row_found = false
|
||||
last_row = True
|
||||
current_row = start_row
|
||||
|
||||
For i = start_row To 9999
|
||||
current_row = i
|
||||
last_row_found = checkAdjustmentSheetLastRow(current_row)
|
||||
|
||||
if (last_row_found = true) then
|
||||
exit for
|
||||
end if
|
||||
Next i
|
||||
|
||||
getAdjustmentSheetListEnd = current_row -1
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "getAdjustmentSheetListEnd:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Sub helloworld()
|
||||
On Error GoTo eh
|
||||
Dim need_to_copy as boolean
|
||||
|
||||
Dim adjustment_sheet_last_row as integer
|
||||
Dim adjustment_sheet_current_row as integer
|
||||
|
||||
Dim bmf_adjustment_sheet_last_row as integer
|
||||
Dim bmf_adjustment_sheet_current_row as integer
|
||||
|
||||
init
|
||||
'MsgBox "helloworld"
|
||||
adjustment_sheet_last_row= getAdjustmentSheetListEnd(first_row)
|
||||
|
||||
For adjustment_sheet_current_row = 6 To adjustment_sheet_last_row
|
||||
need_to_copy = false
|
||||
|
||||
Dim bmf_id as string
|
||||
Dim pcco as string
|
||||
bmf_id = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_FINAL_BMF_ID & CStr(adjustment_sheet_current_row)).Value
|
||||
pcco=Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_PCCO_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
|
||||
if (CheckIfBalanceSheetAmountToAdjust2Exist(adjustment_sheet_current_row) and CheckIfBalanceSheetNa2Exist(adjustment_sheet_current_row) and CheckIfBalanceSheetPcco2Exist(adjustment_sheet_current_row)) then
|
||||
if (CheckIfBalanceSheetAmountToAdjust2IsZero(adjustment_sheet_current_row)) then
|
||||
debug.print Cstr(adjustment_sheet_current_row) & " no need to copy as zero"
|
||||
|
||||
elseif (checkIfAlreadyExistInBmfAdjustmentResult(bmf_id, pcco)) then
|
||||
debug.print "already exist in bmf table, skipping"
|
||||
else
|
||||
need_to_copy = True
|
||||
end if
|
||||
end if
|
||||
|
||||
' helloworld
|
||||
if (need_to_copy = true) then
|
||||
debug.print adjustment_sheet_current_row & " need to copy"
|
||||
bmf_adjustment_sheet_last_row = getBMFAdjustmentResultListEnd(1)
|
||||
bmf_adjustment_sheet_current_row = bmf_adjustment_sheet_last_row + 1
|
||||
|
||||
Dim temp_value as string
|
||||
|
||||
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_REPORTING_ENTITY & CStr(bmf_adjustment_sheet_current_row)).Value = "14004"
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_OPAQUE_REPORTING_ENTITY & CStr(bmf_adjustment_sheet_current_row)).Value = "N"
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_NA_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_LOCAL_OPERATIONAL_ACCOUNT & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value & " 15130"
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_PCCO_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_PCCO & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_AMOUNT_TO_ADJ_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_FINAL_BMF_ID & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
|
||||
' update formatting
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE & CStr(bmf_adjustment_sheet_current_row)).NumberFormat = "#,##_);[Red](#,##)"
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT & CStr(bmf_adjustment_sheet_current_row)).NumberFormat = "#,##_);[Red](#,##)"
|
||||
|
||||
|
||||
else
|
||||
debug.print adjustment_sheet_current_row & " no need to copy"
|
||||
end if
|
||||
|
||||
|
||||
Next adjustment_sheet_current_row
|
||||
|
||||
Done:
|
||||
Exit Sub
|
||||
|
||||
eh:
|
||||
Debug.Print "helloworld:Error: " & Err.Description
|
||||
|
||||
End Sub
|
BIN
task2/draft2/Copy and Paste.xlsm
Normal file
BIN
task2/draft2/Copy and Paste.xlsm
Normal file
Binary file not shown.
BIN
task2/draft2/Copy and Paste.xlsx
Normal file
BIN
task2/draft2/Copy and Paste.xlsx
Normal file
Binary file not shown.
727
task2/draft2/ThisWorkbook.cls
Normal file
727
task2/draft2/ThisWorkbook.cls
Normal file
@@ -0,0 +1,727 @@
|
||||
' change log:
|
||||
|
||||
Option Explicit
|
||||
|
||||
Dim first_row As Integer
|
||||
Dim current_row As Integer
|
||||
Dim last_check_row As Integer
|
||||
|
||||
Dim ADJUSTMENT_WORKSHEET As String
|
||||
Dim BMF_ADJUSTMENT_WORKSHEET As String
|
||||
|
||||
' BALANCE_SHEET
|
||||
Dim COL_BALANCE_SHEET_NA_1 As String
|
||||
Dim COL_BALANCE_SHEET_PCCO_1 As String
|
||||
Dim COL_BALANCE_SHEET_AMOUNT_TO_ADJ_1 As String
|
||||
|
||||
Dim COL_BALANCE_SHEET_NA_2 As String
|
||||
Dim COL_BALANCE_SHEET_PCCO_2 As String
|
||||
Dim COL_BALANCE_SHEET_AMOUNT_TO_ADJ_2 As String
|
||||
|
||||
' OFF_BALANCE_SHEET
|
||||
Dim COL_OFF_BALANCE_SHEET_NA_1 As String
|
||||
Dim COL_OFF_BALANCE_SHEET_PCCO_1 As String
|
||||
Dim COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_1 As String
|
||||
|
||||
Dim COL_OFF_BALANCE_SHEET_NA_2 As String
|
||||
Dim COL_OFF_BALANCE_SHEET_PCCO_2 As String
|
||||
Dim COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_2 As String
|
||||
|
||||
Dim COL_FINAL_BMF_ID As String
|
||||
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_LINE_TYPE As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_ADJUSTMENT_ID As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_ADJUSTMENT_TYPE As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_COMMENT As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_REPORTING_ENTITY As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_PCCO As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_PCEC As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_ACCOUNTING_BALANCE_CURRENCY As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_FAIR_VALUE As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_ECONOMIC_AGENT As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_OPAQUE_REPORTING_ENTITY As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_REMAINING_MATURITY As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_IFRS13 As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_COUNTRY As String
|
||||
Dim COL_BMF_ADJUSTMENT_SHEET_LOCAL_OPERATIONAL_ACCOUNT As String
|
||||
|
||||
Dim RED_THOUSAND_SEP_NUMBER_FORMAT as string
|
||||
|
||||
Sub init()
|
||||
On Error GoTo eh
|
||||
|
||||
RED_THOUSAND_SEP_NUMBER_FORMAT = "#,##0_);[Red](#,##0)"
|
||||
|
||||
' HEADER_ROW = 6
|
||||
first_row = 6
|
||||
current_row = first_row
|
||||
last_check_row = 9999
|
||||
|
||||
' ADJUSTMENT_SHEET
|
||||
ADJUSTMENT_WORKSHEET = "Adjustment"
|
||||
|
||||
' BALANCE_SHEET
|
||||
COL_BALANCE_SHEET_NA_1 = "Q"
|
||||
COL_BALANCE_SHEET_PCCO_1 = "R"
|
||||
COL_BALANCE_SHEET_AMOUNT_TO_ADJ_1 = "S"
|
||||
|
||||
COL_BALANCE_SHEET_NA_2 = "T"
|
||||
COL_BALANCE_SHEET_PCCO_2 = "U"
|
||||
COL_BALANCE_SHEET_AMOUNT_TO_ADJ_2 = "V"
|
||||
|
||||
' OFF_BALANCE_SHEET
|
||||
COL_OFF_BALANCE_SHEET_NA_1 = "X"
|
||||
COL_OFF_BALANCE_SHEET_PCCO_1 = "Y"
|
||||
COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_1 = "Z"
|
||||
|
||||
COL_OFF_BALANCE_SHEET_NA_2 = "AA"
|
||||
COL_OFF_BALANCE_SHEET_PCCO_2 = "AB"
|
||||
COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_2 = "AC"
|
||||
|
||||
COL_FINAL_BMF_ID = "AI"
|
||||
|
||||
' BMF_ADJUSTMENT_SHEET
|
||||
BMF_ADJUSTMENT_WORKSHEET = "BMF Adjustment"
|
||||
COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID = "A"
|
||||
COL_BMF_ADJUSTMENT_SHEET_LINE_TYPE = "B"
|
||||
COL_BMF_ADJUSTMENT_SHEET_ADJUSTMENT_ID = "C"
|
||||
COL_BMF_ADJUSTMENT_SHEET_ADJUSTMENT_TYPE = "D"
|
||||
COL_BMF_ADJUSTMENT_SHEET_COMMENT = "E"
|
||||
COL_BMF_ADJUSTMENT_SHEET_REPORTING_ENTITY = "F"
|
||||
COL_BMF_ADJUSTMENT_SHEET_PCCO = "G"
|
||||
COL_BMF_ADJUSTMENT_SHEET_PCEC = "H"
|
||||
COL_BMF_ADJUSTMENT_SHEET_ACCOUNTING_BALANCE_CURRENCY = "I"
|
||||
COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE = "J"
|
||||
COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT = "K"
|
||||
COL_BMF_ADJUSTMENT_SHEET_FAIR_VALUE = "BH"
|
||||
COL_BMF_ADJUSTMENT_SHEET_ECONOMIC_AGENT = "BI"
|
||||
COL_BMF_ADJUSTMENT_SHEET_OPAQUE_REPORTING_ENTITY = "BJ"
|
||||
COL_BMF_ADJUSTMENT_SHEET_REMAINING_MATURITY = "BK"
|
||||
COL_BMF_ADJUSTMENT_SHEET_IFRS13 = "BL"
|
||||
COL_BMF_ADJUSTMENT_SHEET_COUNTRY = "BM"
|
||||
COL_BMF_ADJUSTMENT_SHEET_LOCAL_OPERATIONAL_ACCOUNT = "BN"
|
||||
|
||||
Done:
|
||||
Debug.Print "init done"
|
||||
Exit Sub
|
||||
|
||||
eh:
|
||||
Debug.Print "init:Error: " & Err.Description
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
function paintYellow(cell as variant)
|
||||
cell.Interior.Color = rgb(246, 229, 141)
|
||||
paintYellow = True
|
||||
end function
|
||||
|
||||
function paintRed(cell as variant)
|
||||
cell.Interior.Color = rgb(255, 121, 121)
|
||||
paintRed = True
|
||||
end function
|
||||
|
||||
Function CheckIfOffBalanceSheetAmountToAdjust1NoNeedCopy(current_row As Integer, bmf_id As String, pcco As String)
|
||||
On Error GoTo eh
|
||||
Dim output As Boolean
|
||||
output = False
|
||||
Dim temp As String
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_1 & CStr(current_row)).Value
|
||||
|
||||
If ( temp = "") Then
|
||||
output = True
|
||||
ElseIf (temp = "0") Then
|
||||
paintYellow(Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_1 & CStr(current_row)))
|
||||
output = True
|
||||
ElseIf (checkIfAlreadyExistInBmfAdjustmentResult(bmf_id, pcco, current_row)) Then
|
||||
paintRed(Worksheets(ADJUSTMENT_WORKSHEET).Range("AI" & CStr(current_row)))
|
||||
paintRed(Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_PCCO_1 & CStr(current_row)))
|
||||
|
||||
output = True
|
||||
End If
|
||||
|
||||
|
||||
CheckIfOffBalanceSheetAmountToAdjust1NoNeedCopy = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfOffBalanceSheetAmountToAdjust1NoNeedCopy:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function CheckIfAdjustmentSheetBmfIdValid(current_row As Integer)
|
||||
On Error GoTo eh
|
||||
Dim output As Boolean
|
||||
output = False
|
||||
Dim temp As String
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_FINAL_BMF_ID & CStr(current_row)).Value
|
||||
|
||||
If (temp <> "") Then
|
||||
output = True
|
||||
End If
|
||||
|
||||
CheckIfAdjustmentSheetBmfIdValid = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfAdjustmentSheetBmfIdValid:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Function CheckIfOffBalanceSheetAmountToAdjust2NoNeedCopy(current_row As Integer, bmf_id As String, pcco As String)
|
||||
On Error GoTo eh
|
||||
Dim output As Boolean
|
||||
output = False
|
||||
Dim temp As String
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_2 & CStr(current_row)).Value
|
||||
|
||||
If ( temp = "") Then
|
||||
output = True
|
||||
ElseIf (temp = "0") Then
|
||||
paintYellow(Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_2 & CStr(current_row)))
|
||||
output = True
|
||||
ElseIf (checkIfAlreadyExistInBmfAdjustmentResult(bmf_id, pcco, current_row)) Then
|
||||
paintRed(Worksheets(ADJUSTMENT_WORKSHEET).Range("AI" & CStr(current_row)))
|
||||
paintRed(Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_PCCO_2 & CStr(current_row)))
|
||||
output = True
|
||||
End If
|
||||
|
||||
|
||||
CheckIfOffBalanceSheetAmountToAdjust2NoNeedCopy = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfOffBalanceSheetAmountToAdjust2NoNeedCopy:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Function CheckIfBalanceSheetAmountToAdjust1NoNeedCopy(current_row As Integer, bmf_id As String, pcco As String)
|
||||
On Error GoTo eh
|
||||
Dim output As Boolean
|
||||
output = False
|
||||
|
||||
Dim temp As String
|
||||
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_AMOUNT_TO_ADJ_1 & CStr(current_row)).Value
|
||||
Debug.Print "CheckIfBalanceSheetAmountToAdjust1NoNeedCopy:" & temp = "0"
|
||||
|
||||
If ( temp = "") Then
|
||||
output = True
|
||||
ElseIf (temp = "0") Then
|
||||
paintYellow(Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_AMOUNT_TO_ADJ_1 & CStr(current_row)))
|
||||
output = True
|
||||
ElseIf (checkIfAlreadyExistInBmfAdjustmentResult(bmf_id, pcco, current_row)) Then
|
||||
paintRed(Worksheets(ADJUSTMENT_WORKSHEET).Range("AI" & CStr(current_row)))
|
||||
paintRed(Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_PCCO_1 & CStr(current_row)))
|
||||
output = True
|
||||
End If
|
||||
|
||||
CheckIfBalanceSheetAmountToAdjust1NoNeedCopy = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfBalanceSheetAmountToAdjust1NoNeedCopy:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function CheckIfBalanceSheetAmountToAdjust2NoNeedCopy(current_row As Integer, bmf_id As String, pcco As String)
|
||||
On Error GoTo eh
|
||||
Dim output As Boolean
|
||||
output = False
|
||||
Dim temp As String
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_AMOUNT_TO_ADJ_2 & CStr(current_row)).Value
|
||||
|
||||
If ( temp = "") Then
|
||||
output = True
|
||||
ElseIf (temp = "0") Then
|
||||
paintYellow(Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_AMOUNT_TO_ADJ_2 & CStr(current_row)))
|
||||
output = True
|
||||
ElseIf (checkIfAlreadyExistInBmfAdjustmentResult(bmf_id, pcco, current_row)) Then
|
||||
paintRed(Worksheets(ADJUSTMENT_WORKSHEET).Range("AI" & CStr(current_row)))
|
||||
paintRed(Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_PCCO_2 & CStr(current_row)))
|
||||
output = True
|
||||
End If
|
||||
|
||||
|
||||
CheckIfBalanceSheetAmountToAdjust2NoNeedCopy = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfBalanceSheetAmountToAdjust2NoNeedCopy:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Function CheckIfBalanceSheetNa2Exist(current_row As Integer)
|
||||
On Error GoTo eh
|
||||
Dim output As Boolean
|
||||
output = False
|
||||
Dim temp As String
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_NA_2 & CStr(current_row)).Value
|
||||
|
||||
If (temp <> "") Then
|
||||
output = True
|
||||
End If
|
||||
|
||||
CheckIfBalanceSheetNa2Exist = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfBalanceSheetNa2Exist:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function CheckIfBalanceSheetPcco2Exist(current_row As Integer)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim output As Boolean
|
||||
output = False
|
||||
Dim temp As String
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_PCCO_2 & CStr(current_row)).Value
|
||||
|
||||
If (temp <> "") Then
|
||||
output = True
|
||||
End If
|
||||
|
||||
CheckIfBalanceSheetPcco2Exist = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfBalanceSheetPcco2Exist:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function CheckIfBalanceSheetAmountToAdjust2Exist(current_row As Integer)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim output As Boolean
|
||||
output = False
|
||||
Dim temp As String
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_AMOUNT_TO_ADJ_2 & CStr(current_row)).Value
|
||||
|
||||
If (temp <> "") Then
|
||||
output = True
|
||||
End If
|
||||
|
||||
CheckIfBalanceSheetAmountToAdjust2Exist = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "CheckIfBalanceSheetAmountToAdjust2Exist:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function isCurrentRowNeedToProcess(input_row As Integer)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim output As Boolean
|
||||
Dim cell_value As Currency
|
||||
Dim input_cell As String
|
||||
input_cell = GRANDTOTAL_COL & input_row
|
||||
|
||||
Done:
|
||||
isCurrentRowNeedToProcess = Not (IsEmpty(Worksheets(ADJUSTMENT_WORKSHEET).Range(input_cell).Value))
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "isCurrentRowNeedToProcess:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function getLastCheckRow(first_row As Integer)
|
||||
On Error GoTo eh
|
||||
getLastCheckRow = first_row + 10
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "getLastCheckRow:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function checkAdjustmentSheetLastRow(current_row As Integer)
|
||||
On Error GoTo eh
|
||||
Dim output As Boolean
|
||||
output = True
|
||||
|
||||
Dim j As Integer
|
||||
Dim temp As String
|
||||
|
||||
For j = current_row To getLastCheckRow(current_row)
|
||||
temp = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_FINAL_BMF_ID & CStr(current_row)).Value
|
||||
If (temp <> "") Then
|
||||
output = False
|
||||
End If
|
||||
Next j
|
||||
|
||||
checkAdjustmentSheetLastRow = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "checkAdjustmentSheetLastRow:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function checkBmfAdjustmentSheetLastRow(current_row As Integer)
|
||||
On Error GoTo eh
|
||||
Dim output As Boolean
|
||||
output = True
|
||||
|
||||
Dim j As Integer
|
||||
Dim temp As String
|
||||
|
||||
For j = current_row To getLastCheckRow(current_row)
|
||||
temp = Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(current_row)).Value
|
||||
If (temp <> "") Then
|
||||
output = False
|
||||
End If
|
||||
Next j
|
||||
|
||||
checkBmfAdjustmentSheetLastRow = output
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "checkBmfAdjustmentSheetLastRow:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function checkIfAlreadyExistInBmfAdjustmentResult(adj_bmf_id As String, adj_pcco As String, adj_sheet_row As Integer)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim i As Integer
|
||||
Dim bmf_adjustment_sheet_last_row As Integer
|
||||
Dim found As Boolean
|
||||
found = False
|
||||
Dim temp_value As String
|
||||
Dim bmf_adj_bmf_id As String
|
||||
Dim bmf_adj_pcco As String
|
||||
|
||||
Application.ScreenUpdating = False
|
||||
|
||||
|
||||
bmf_adjustment_sheet_last_row = getBMFAdjustmentResultListEnd(1)
|
||||
|
||||
For i = 1 To bmf_adjustment_sheet_last_row
|
||||
bmf_adj_bmf_id = Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(i)).Value
|
||||
bmf_adj_pcco = Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_PCCO & CStr(i)).Value
|
||||
|
||||
' debug.print bmf_adj_bmf_id
|
||||
' debug.print bmf_adj_pcco
|
||||
' debug.print adj_bmf_id
|
||||
' debug.print adj_pcco
|
||||
' debug.print bmf_adj_bmf_id = adj_bmf_id And bmf_adj_pcco = adj_pcco
|
||||
|
||||
|
||||
If (bmf_adj_bmf_id = adj_bmf_id And bmf_adj_pcco = adj_pcco) Then
|
||||
|
||||
' Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range("B"&cstr(i)).value = Cstr(bmf_adj_bmf_id = adj_bmf_id)
|
||||
' Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range("B"&cstr(i)).value = Cstr(bmf_adj_pcco = adj_pcco)
|
||||
|
||||
'Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(i)).Interior.Color = RGB(214, 48, 49)
|
||||
paintRed(Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(i)))
|
||||
' Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_PCCO & CStr(i)).Interior.Color = RGB(214, 48, 49)
|
||||
paintred(Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_PCCO & CStr(i)))
|
||||
|
||||
' adj_sheet_row
|
||||
|
||||
|
||||
found = True
|
||||
|
||||
Exit For
|
||||
End If
|
||||
Next i
|
||||
|
||||
checkIfAlreadyExistInBmfAdjustmentResult = found
|
||||
|
||||
Application.ScreenUpdating = True
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Application.ScreenUpdating = True
|
||||
|
||||
Debug.Print "checkIfAlreadyExistInBmfAdjustmentResult:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function getBMFAdjustmentResultListEnd(start_row As Integer)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim i As Integer
|
||||
|
||||
Dim last_row As Boolean
|
||||
Dim last_row_found As Boolean
|
||||
last_row_found = False
|
||||
last_row = True
|
||||
current_row = start_row
|
||||
|
||||
For i = start_row To 9999
|
||||
current_row = i
|
||||
last_row_found = checkBmfAdjustmentSheetLastRow(current_row)
|
||||
|
||||
If (last_row_found = True) Then
|
||||
Exit For
|
||||
End If
|
||||
Next i
|
||||
|
||||
getBMFAdjustmentResultListEnd = current_row - 1
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "getBMFAdjustmentResultListEnd:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
Function getAdjustmentSheetListEnd(start_row As Integer)
|
||||
On Error GoTo eh
|
||||
|
||||
Dim i As Integer
|
||||
|
||||
Dim last_row As Boolean
|
||||
Dim last_row_found As Boolean
|
||||
last_row_found = False
|
||||
last_row = True
|
||||
current_row = start_row
|
||||
|
||||
For i = start_row To 9999
|
||||
current_row = i
|
||||
last_row_found = checkAdjustmentSheetLastRow(current_row)
|
||||
|
||||
If (last_row_found = True) Then
|
||||
Exit For
|
||||
End If
|
||||
Next i
|
||||
|
||||
getAdjustmentSheetListEnd = current_row - 1
|
||||
|
||||
Done:
|
||||
Exit Function
|
||||
|
||||
eh:
|
||||
Debug.Print "getAdjustmentSheetListEnd:Error: " & Err.Description
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Sub resetBmfAdjustmentSheet()
|
||||
init
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range("A4:BN9999").Clear
|
||||
|
||||
end sub
|
||||
|
||||
Sub helloworld()
|
||||
On Error GoTo eh
|
||||
Dim need_to_copy As Boolean
|
||||
|
||||
Dim adjustment_sheet_first_row As Integer
|
||||
Dim adjustment_sheet_last_row As Integer
|
||||
Dim adjustment_sheet_current_row As Integer
|
||||
|
||||
Dim bmf_adjustment_sheet_last_row As Integer
|
||||
Dim bmf_adjustment_sheet_current_row As Integer
|
||||
|
||||
Dim temp_value As String
|
||||
|
||||
adjustment_sheet_first_row = 7
|
||||
|
||||
init
|
||||
' MsgBox "helloworld"
|
||||
adjustment_sheet_last_row = getAdjustmentSheetListEnd(adjustment_sheet_first_row)
|
||||
Debug.Print adjustment_sheet_last_row
|
||||
|
||||
For adjustment_sheet_current_row = adjustment_sheet_first_row To adjustment_sheet_last_row
|
||||
Debug.Print "processing adjustment_sheet_current_row: " & adjustment_sheet_current_row
|
||||
|
||||
' if (CheckIfBalanceSheetAmountToAdjust2Exist(adjustment_sheet_current_row) and CheckIfBalanceSheetNa2Exist(adjustment_sheet_current_row) and CheckIfBalanceSheetPcco2Exist(adjustment_sheet_current_row)) then
|
||||
If (CheckIfAdjustmentSheetBmfIdValid(adjustment_sheet_current_row)) Then
|
||||
Debug.Print "processing row: " & adjustment_sheet_current_row
|
||||
|
||||
Dim bmf_id As String
|
||||
bmf_id = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_FINAL_BMF_ID & CStr(adjustment_sheet_current_row)).Value
|
||||
|
||||
Dim bal_pcco_1 As String
|
||||
bal_pcco_1 = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_PCCO_1 & CStr(adjustment_sheet_current_row)).Value
|
||||
|
||||
Dim bal_pcco_2 As String
|
||||
bal_pcco_2 = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_PCCO_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
|
||||
Dim off_bal_pcco_1 As String
|
||||
off_bal_pcco_1 = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_PCCO_1 & CStr(adjustment_sheet_current_row)).Value
|
||||
|
||||
Dim off_bal_pcco_2 As String
|
||||
off_bal_pcco_2 = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_PCCO_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
|
||||
' balance sheet 1
|
||||
' check need to copy ? see amount to adjust <> 0 ?
|
||||
If (CheckIfBalanceSheetAmountToAdjust1NoNeedCopy(adjustment_sheet_current_row, bmf_id, bal_pcco_1) = True) Then
|
||||
' do skip
|
||||
Debug.Print "skip balance sheet 1"
|
||||
Else
|
||||
' do copy
|
||||
bmf_adjustment_sheet_last_row = getBMFAdjustmentResultListEnd(1)
|
||||
bmf_adjustment_sheet_current_row = bmf_adjustment_sheet_last_row + 1
|
||||
Debug.Print "bmf_adjustment_sheet_current_row:" & bmf_adjustment_sheet_current_row
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_FINAL_BMF_ID & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_REPORTING_ENTITY & CStr(bmf_adjustment_sheet_current_row)).Value = "14004"
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_OPAQUE_REPORTING_ENTITY & CStr(bmf_adjustment_sheet_current_row)).Value = "N"
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_PCCO_1 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_PCCO & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_AMOUNT_TO_ADJ_1 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_NA_1 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_LOCAL_OPERATIONAL_ACCOUNT & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value & " " & "15130"
|
||||
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range("A" & bmf_adjustment_sheet_current_row & ":" & "BN" & bmf_adjustment_sheet_current_row).NumberFormat = "@"
|
||||
' Selection.NumberFormat = RED_THOUSAND_SEP_NUMBER_FORMAT
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE & bmf_adjustment_sheet_current_row).NumberFormat = RED_THOUSAND_SEP_NUMBER_FORMAT
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT & bmf_adjustment_sheet_current_row).NumberFormat = RED_THOUSAND_SEP_NUMBER_FORMAT
|
||||
|
||||
|
||||
|
||||
End If
|
||||
|
||||
' balance sheet 2
|
||||
' check need to copy ? see amount to adjust <> 0 ?
|
||||
debug.print bal_pcco_2
|
||||
If (CheckIfBalanceSheetAmountToAdjust2NoNeedCopy(adjustment_sheet_current_row, bmf_id, bal_pcco_2)) Then
|
||||
' do skip
|
||||
Debug.Print "skip balance sheet 2"
|
||||
Else
|
||||
' do copy
|
||||
bmf_adjustment_sheet_last_row = getBMFAdjustmentResultListEnd(1)
|
||||
bmf_adjustment_sheet_current_row = bmf_adjustment_sheet_last_row + 1
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_FINAL_BMF_ID & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_REPORTING_ENTITY & CStr(bmf_adjustment_sheet_current_row)).Value = "14004"
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_OPAQUE_REPORTING_ENTITY & CStr(bmf_adjustment_sheet_current_row)).Value = "N"
|
||||
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_PCCO_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_PCCO & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_AMOUNT_TO_ADJ_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_BALANCE_SHEET_NA_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_LOCAL_OPERATIONAL_ACCOUNT & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value & " " & "15130"
|
||||
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range("A" & bmf_adjustment_sheet_current_row & ":" & "BN" & bmf_adjustment_sheet_current_row).NumberFormat = "@"
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE & bmf_adjustment_sheet_current_row).NumberFormat = RED_THOUSAND_SEP_NUMBER_FORMAT
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT & bmf_adjustment_sheet_current_row).NumberFormat = RED_THOUSAND_SEP_NUMBER_FORMAT
|
||||
|
||||
End If
|
||||
|
||||
' off-balance sheet 1
|
||||
' check need to copy ? see amount to adjust <> 0 ?
|
||||
If (CheckIfOffBalanceSheetAmountToAdjust1NoNeedCopy(adjustment_sheet_current_row, bmf_id, off_bal_pcco_1)) Then
|
||||
' do skip
|
||||
Debug.Print "skip off-balance sheet 1"
|
||||
Else
|
||||
' do copy
|
||||
bmf_adjustment_sheet_last_row = getBMFAdjustmentResultListEnd(1)
|
||||
bmf_adjustment_sheet_current_row = bmf_adjustment_sheet_last_row + 1
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_FINAL_BMF_ID & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_REPORTING_ENTITY & CStr(bmf_adjustment_sheet_current_row)).Value = "14004"
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_OPAQUE_REPORTING_ENTITY & CStr(bmf_adjustment_sheet_current_row)).Value = "N"
|
||||
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_PCCO_1 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_PCCO & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_1 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_NA_1 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_LOCAL_OPERATIONAL_ACCOUNT & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value & " " & "15130"
|
||||
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range("A" & bmf_adjustment_sheet_current_row & ":" & "BN" & bmf_adjustment_sheet_current_row).NumberFormat = "@"
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE & bmf_adjustment_sheet_current_row).NumberFormat = RED_THOUSAND_SEP_NUMBER_FORMAT
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT & bmf_adjustment_sheet_current_row).NumberFormat = RED_THOUSAND_SEP_NUMBER_FORMAT
|
||||
|
||||
End If
|
||||
|
||||
' off-balance sheet 2
|
||||
' check need to copy ? see amount to adjust <> 0 ?
|
||||
If (CheckIfOffBalanceSheetAmountToAdjust2NoNeedCopy(adjustment_sheet_current_row, bmf_id, off_bal_pcco_2)) Then
|
||||
' do skip
|
||||
Debug.Print "skip off-balance sheet 2"
|
||||
Else
|
||||
' do copy
|
||||
bmf_adjustment_sheet_last_row = getBMFAdjustmentResultListEnd(1)
|
||||
bmf_adjustment_sheet_current_row = bmf_adjustment_sheet_last_row + 1
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_FINAL_BMF_ID & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_BMF_REFERENCE_ID & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_REPORTING_ENTITY & CStr(bmf_adjustment_sheet_current_row)).Value = "14004"
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_OPAQUE_REPORTING_ENTITY & CStr(bmf_adjustment_sheet_current_row)).Value = "N"
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_PCCO_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_PCCO & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_AMOUNT_TO_ADJ_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value
|
||||
|
||||
temp_value = Worksheets(ADJUSTMENT_WORKSHEET).Range(COL_OFF_BALANCE_SHEET_NA_2 & CStr(adjustment_sheet_current_row)).Value
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_LOCAL_OPERATIONAL_ACCOUNT & CStr(bmf_adjustment_sheet_current_row)).Value = temp_value & " " & "15130"
|
||||
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range("A" & bmf_adjustment_sheet_current_row & ":" & "BN" & bmf_adjustment_sheet_current_row).NumberFormat = "@"
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_ACCT_BALANCE & bmf_adjustment_sheet_current_row).NumberFormat = RED_THOUSAND_SEP_NUMBER_FORMAT
|
||||
Worksheets(BMF_ADJUSTMENT_WORKSHEET).Range(COL_BMF_ADJUSTMENT_SHEET_AMOUNT_IN_FUNT & bmf_adjustment_sheet_current_row).NumberFormat = RED_THOUSAND_SEP_NUMBER_FORMAT
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
Debug.Print adjustment_sheet_current_row & " skipping copy as bmfid is empty"
|
||||
End If
|
||||
|
||||
|
||||
Next adjustment_sheet_current_row
|
||||
|
||||
Done:
|
||||
Exit Sub
|
||||
|
||||
eh:
|
||||
Debug.Print "helloworld:Error: " & Err.Description
|
||||
|
||||
End Sub
|
||||
|
24
task2/notes.md
Normal file
24
task2/notes.md
Normal file
@@ -0,0 +1,24 @@
|
||||
ttps://share-staging.louislabs.com/g/u-5_gKrQtGa
|
||||
|
||||
Q: 我見你個 screen capture 係 mac , 我想問下你會係 mac 定 window 度行?
|
||||
A: Window行的🙆🏻♀️🙆🏻♀️ 同上次一樣
|
||||
|
||||
# 我今次想做嘅野係將 adjustment 嘅資料 copy and paste 去到 BMF Adjustment 到
|
||||
|
||||

|
||||
|
||||
係 adjustment tab,你見到我圈咗4樣野分別寫咗1, 2, 3, 4
|
||||
|
||||
1. 每一行 copy 嘅 data 要連埋 AI column 嘅 BMF ID
|
||||
1. 第 2 個圈住嘅 data 唔係次次都會有,所以想有 value 先 copy and paste 上去
|
||||
- check if BalanceSheet_NA2 exist
|
||||
- check if BalanceSheet_PCCO2 exist
|
||||
- check if BalanceSheet_Amount_TO_ADJUST2 exist
|
||||
1. 如果 amount to adj 係 0, 就唔洗 copy and paste
|
||||
1. 係 BMF Adjustment tab 到,
|
||||
- 如果copy and paste咗過去,"reporting entity" columns 填 14004
|
||||
- 如果copy and paste咗過去,"Opaque reporting entity" columns 填 N
|
||||
1. 係BMF Adjustment tab到,
|
||||
- 個 "local operational Account" 就係 Adjustment tab 入面嘅 "NA" 加返 "15130"
|
||||
|
||||
我share 咗個sample file俾你 你幫我睇睇大概要幾錢🙇🏻♀️
|
13
task2/package.json
Normal file
13
task2/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "task2",
|
||||
"version": "1.0.0",
|
||||
"description": "excel adjustment",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"gitUpdate":"git add . && git commit -m\"update natalie0312,\""
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
Reference in New Issue
Block a user