'--------------------------------------------------------------------------------------------------------- |
|
Function fn_Replace_symbols(ByVal txt As String) As String |
|
St$ = "~!@/\#$%^:?&*=|`;""" |
|
txt = Replace(txt, Mid(St$, f_i, 1), "_") |
|
txt = Replace(txt, Chr(10), "_") |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_VBA_Start() As String |
|
.Calculation = xlCalculationManual |
|
'.DisplayPageBreaks = False |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_VBA_End() As String |
|
.Calculation = xlCalculationAutomatic |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_CreateSh(cr_sh As String) As String |
|
For Each Sh In ThisWorkbook.Worksheets |
|
Set Sh = Worksheets.Add() |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_openFile(ByRef patch As String, nm_sh As String) As String |
|
Workbooks.Open Filename:=patch, Notify:=False |
|
result = ActiveWorkbook.Name |
|
ActiveSheet.AutoFilterMode = False |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_openFileCSV(ByRef patch As String) |
|
Workbooks.OpenText Filename:=patch, _ |
|
Origin:=65001, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ |
|
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, _ |
|
Comma:=False, Space:=False, Other:=False, TrailingMinusNumbers:=True |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_quartal(month&) As String |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_month_form_00(month As Integer) As String |
|
fn_month_form_00 = result |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_patch_history_TR(brand As String, year As Integer, thisMonth As Integer, ver_month As String) As String |
|
result = "p:\DPP\Business development\Book commercial\" & brand & "\Top Russia Total " & year & " " & brand & ".xlsm" |
|
result = "p:\DPP\Business development\Book commercial\" & brand & "\" & year & "\History " & year & "\Top Russia Total " & year & "." & ver_month & " " & brand & ".xlsm" |
|
fn_patch_history_TR = result |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_num_LastRow() As Integer |
|
With ActiveWorkbook.ActiveSheet.UsedRange |
|
result = .Row + .Rows.Count - 1 |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_lastColumn() As Integer |
|
With ActiveWorkbook.ActiveSheet.UsedRange |
|
result = .Column + .Columns.Count - 1 |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_clnt_type(in_data$, i&) |
|
Dim ar_type_clients(1 To 4, 1 To 12) |
|
ar_type_clients(1, 1) = "салон" |
|
ar_type_clients(2, 1) = "salon" |
|
ar_type_clients(3, 1) = "salon" |
|
ar_type_clients(4, 1) = "single" |
|
ar_type_clients(1, 2) = "сеть салонов" |
|
ar_type_clients(2, 2) = "chain_salons" |
|
ar_type_clients(3, 2) = "salon" |
|
ar_type_clients(4, 2) = "chain" |
|
ar_type_clients(1, 3) = "ч/м" |
|
ar_type_clients(2, 3) = "hdres" |
|
ar_type_clients(3, 3) = "salon" |
|
ar_type_clients(4, 3) = "single" |
|
ar_type_clients(1, 4) = "сеть магазинов" |
|
ar_type_clients(2, 4) = "chain_shops" |
|
ar_type_clients(3, 4) = "shop" |
|
ar_type_clients(4, 4) = "chain" |
|
ar_type_clients(1, 5) = "магазин" |
|
ar_type_clients(2, 5) = "shop" |
|
ar_type_clients(3, 5) = "shop" |
|
ar_type_clients(4, 5) = "single" |
|
ar_type_clients(1, 6) = "салон-маг." |
|
ar_type_clients(2, 6) = "salon" |
|
ar_type_clients(3, 6) = "salon" |
|
ar_type_clients(4, 6) = "single" |
|
ar_type_clients(1, 7) = "(пусто)" |
|
ar_type_clients(2, 7) = "other" |
|
ar_type_clients(3, 7) = "other" |
|
ar_type_clients(4, 7) = "single" |
|
ar_type_clients(1, 8) = "школа" |
|
ar_type_clients(2, 8) = "school" |
|
ar_type_clients(3, 8) = "school" |
|
ar_type_clients(4, 8) = "single" |
|
ar_type_clients(1, 9) = "другое" |
|
ar_type_clients(2, 9) = "other" |
|
ar_type_clients(3, 9) = "other" |
|
ar_type_clients(4, 9) = "single" |
|
ar_type_clients(1, 10) = "нейл-бар" |
|
ar_type_clients(2, 10) = "nails_bar" |
|
ar_type_clients(3, 10) = "nails" |
|
ar_type_clients(4, 10) = "single" |
|
ar_type_clients(1, 11) = "сеть нейл-баров" |
|
ar_type_clients(2, 11) = "chain_nails" |
|
ar_type_clients(3, 11) = "nails" |
|
ar_type_clients(4, 11) = "chain" |
|
ar_type_clients(1, 12) = "e-commerce" |
|
ar_type_clients(2, 12) = "e-commerce" |
|
ar_type_clients(3, 12) = "e-commerce" |
|
ar_type_clients(4, 12) = "single" |
|
If StrComp(ar_type_clients(1, f_sl), LCase(in_data), vbTextCompare) Then |
|
result = ar_type_clients(i, f_sl) |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_mreg_ext$(in_data_mreg$, in_data_reg$) |
|
If LCase(in_data_mreg) = LCase("Moscou GR") Then |
|
textPos = InStr(in_data_reg, "MSK") |
|
textPos = InStr(in_data_reg, "Moscou") + textPos |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_mreg_lat(in_data_mreg As String) As String |
|
Dim ar_nmMregEN(), ar_nmMregLT() |
|
ar_nmMregEN = Array("MOSCOW", "GR", "NORTHWEST", "CENTER", "VOLGA", "SOUTH", "URAL", "SIBERIA", "FAR EAST") |
|
ar_nmMregLT = Array("Moscou", "GR", "Nord-Ouest", "Centre", "Volga-Centre", "Sud", "Oural", "Siberie", "EO") |
|
For f_mr = 0 To UBound(ar_nmMregLT) |
|
If ar_nmMregLT(f_mr) = in_data_mreg Then |
|
result = ar_nmMregEN(f_mr) |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_salon_name$(in_sln_nm$, in_sln_addres$, in_city$) |
|
result = Trim(fn_Replace_symbols(Left(in_sln_nm, 30) & ". " & Left(in_sln_addres, 50) & " " & Left(in_city, 50))) |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_mont_num&(in_data$) |
|
ar_nm_month_qnc_rus = Array("январь", "февраль", "март", "апрель", "май", "июнь", "июль", "август", "сентябрь", "октябрь", "ноябрь", "декабрь") |
|
If ar_nm_month_qnc_rus(f_m) = in_data Then |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_month_eng$(month$) |
|
ar_month_rus = Array("январь", "февраль", "март", "апрель", "май", "июнь", "июль", "август", "сентябрь", "октябрь", "ноябрь", "декабрь") |
|
ar_month_eng = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") |
|
If ar_month_rus(f_m) = month Then |
|
result = ar_month_eng(f_m) |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_getYearType(in_act_year&, in_data&, i&) As Variant |
|
If Len(in_data) = 4 Then result1 = in_data Else result1 = 2008 |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_mag(in_min_price As Long, in_max_price As Long, in_place As Long, mag_type As String) As Variant |
|
If IsNumeric(in_min_price) and IsNumeric(in_max_price) Then |
|
mag_avg_price = Application.WorksheetFunction.Average(in_min_price, in_max_price) |
|
mag_avg_price = in_min_price + in_max_price |
|
Select Case mag_avg_price |
|
Select Case mag_avg_price |
|
Select Case mag_avg_price |
|
If IsNumeric(in_place) Then |
|
in_place = Round(in_place, 0) |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_type_business$(in_brand$) |
|
Case "LP", "MX", "KR", "RD" |
|
fn_type_business = result |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_type_active_DN$(in_data&) |
|
fn_type_active_DN = result |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_rnd_num&(in_data) |
|
If IsNumeric(in_data) And Len(in_data) > 0 Then |
|
result = Round(in_data, 0) |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_num2num0&(in_data As Variant) |
|
If Len(in_data) > 0 And IsNumeric(in_data) Then |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_num2numNull(in_data) As Variant |
|
If Len(in_data) > 0 And in_data <> 0 Then |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_getNmChainTop$(inNmChain$, inCdChain&, inNmTypeClnt$) |
|
If Left(inCdChain, 2) = "92" And fn_clnt_type(inNmTypeClnt, 4) = "chain" Then |
|
fn_getNmChainTop = result |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_GetLTM(in_row&, inThisMonth&, typeFN$) As Variant |
|
Dim f_a&, f_avg&, sum_CA_LTM&, AVG_CA_LTM&, frqOrder& |
|
ar_DataMonthPRTN = Array(66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90) |
|
ar_nmAVG_Order = Array(2.5, 5, 10, 15, 20, 25, 30, 50, 60, 70, 100000) |
|
For f_a = inThisMonth To inThisMonth + 11 |
|
val = Cells(in_row, ar_DataMonthPRTN(f_a)) |
|
If IsNumeric(val) And val > 0 Then |
|
sum_CA_LTM = sum_CA_LTM + val |
|
AVG_CA_LTM = Round(sum_CA_LTM / 12 / 1000, 1) |
|
result = frqOrder & "\12" |
|
For f_avg = 0 To UBound(ar_nmAVG_Order) |
|
MaxVal = ar_nmAVG_Order(f_avg) |
|
If AVG_CA_LTM <= MaxVal And AVG_CA_LTM > MinVal Then result = "'" & MinVal & "-" & MaxVal: Exit For |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_getVectoreEV$(in_data#) |
|
If IsNumeric(in_data) Then |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_getMonthlyCA&(in_row&, in_month&, in_thisMonth&, in_typeY$, in_typeVal$, in_type_period$) |
|
Dim clm_PY_LOR_VAL%, clm_TY_LOR_VAL%, clm_PY_PRTN_VAL%, clm_TY_PRTN_VAL% |
|
Dim ar_Matrix(1 To 2, 1 To 2) |
|
typeF = in_typeY & "_" & in_typeVal |
|
Select Case in_type_period |
|
in_thisMonth = in_thisMonth |
|
val = fn_num2num0(Cells(in_row, clm + in_month - 1)) |
|
If val = 0 Then val = Empty Else val = val / 1000 |
|
'--------------------------------------------------------------------------------------------------------- |
|
For Each wbBook In Workbooks |
|
If wbBook.Name <> ThisWorkbook.Name Then |
|
If Windows(wbBook.Name).Visible Then |
|
If wbBook.Name Like "Top Russia*" Then wbBook.Close: Exit For |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_getCA_Cnq(in_monthQnc&) |
|
fst_order_LOR_PY = Cells(f_i, clm_PYper_LOR_VAL + cd_month_qnc - 1) / 1000 |
|
fst_order_PRTN_PY = Cells(f_i, clm_PYper_PRTN_VAL + cd_month_qnc - 1) / 1000 |
|
If cd_month_qnc = cd_ThisMonth Then |
|
fst_order_LOR_M_PY = Cells(f_i, clm_PYper_LOR_VAL + cd_month_qnc - 1) / 1000 |
|
fst_order_LOR_TY = Cells(f_i, clm_TYper_LOR_VAL + cd_month_qnc - 1) / 1000 |
|
fst_order_PRTN_TY = Cells(f_i, clm_TYper_PRTN_VAL + cd_month_qnc - 1) / 1000 |
|
If cd_month_qnc = cd_ThisMonth Then |
|
fst_order_LOR_M_TY = Cells(f_i, clm_TYper_LOR_VAL + cd_month_qnc - 1) / 1000 |
|
'--------------------------------------------------------------------------------------------------------- |
|
Function fn_avgCA&(in_data&, in_month&) |
|
If Not IsEmpty(in_data) And IsNumeric(in_data) Then |
|
result = in_data / in_month |
|
Dim cd_ThisMonth&, cd_month_qnc& |
|
Dim nm_PatchTR$, nm_brand$, num_LastRow$, nm_Mreg$, nm_Sector$, nm_Mreg_ext$, nm_month_qnc$, nm_business$, nm_Salon$, nm_Salon_addr$, nm_Salon_city$, nm_TypeClntRus$, nm_chain$, nm_Y$, nm_period$ |
|
Dim cd_ThisYear&, mag_min_price&, num_month&, mag_max_price&, mag_hd_place&, cd_year_qnc&, cd_sts_dn_cln&, num_StatusHead&, cd_chain& |
|
Dim f_b&, iii&, i&, x&, y&, frqOrder&, f_i&, f_y&, f_m&, val_ca_PY_YTD&, val_CA_MYTD_PY&, val_ca&, val_ca_cumul&, val_ca_quarter&, val_ca_TY_YTD&, val_CA_MYTD_TY& |
|
Dim ar_Data(), ar_brand(), ar_nmHead() |
|
nm_WB = ActiveWorkbook.Name |
|
cd_ThisMonth = CInt(InputBox("Month")) |
|
'colums CA PRTNN VAL for LTM |
|
'--------------------------------------------------------------------------------------------------------- |
|
ar_month_eng = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") |
|
ar_brand = Array("LP", "KR", "RD", "MX", "ES", "DE", "CR") |
|
num_ar_brand = UBound(ar_brand) |
|
For f_b = 0 To num_ar_brand |
|
nm_PatchTR = "p:\DPP\Business development\Book commercial\" & nm_brand & "\Top Russia Total " & cd_ThisYear & " " & nm_brand & ".xlsm" |
|
nm_ActTR = fn_openFile(nm_PatchTR, nm_brand) |
|
num_LastRow = fn_num_LastRow |
|
For f_i = 4 To num_LastRow |
|
ReDim ar_Data(1 To 100000, 1 To end_clm) |
|
ReDim ar_nmHead(1 To end_clm) |
|
ReDim Preserve ar_Data(1 To 100000, 1 To num_last_colum) |
|
ReDim Preserve ar_nmHead(1 To num_last_colum) |
|
If Not IsEmpty(nm_Mreg) Then iii = iii + 1 |
|
nm_Sector = Cells(f_i, 6) |
|
nm_Mreg_ext = fn_mreg_ext(nm_Mreg, nm_Sector) |
|
nm_Mreg_LT = fn_mreg_lat(nm_Mreg_ext) |
|
nm_FLSM = Cells(f_i, 165) |
|
nm_Salon_addr = Cells(f_i, 12) |
|
nm_Salon_city = Cells(f_i, 11) |
|
nm_month_qnc = Cells(f_i, 64) |
|
cd_month_qnc = fn_mont_num(nm_month_qnc) |
|
cd_year_qnc = fn_getYearType(cd_ThisYear, fn_num2num0(Cells(f_i, 65)), 1) |
|
nm_TypeClntRus = Cells(f_i, 18) |
|
nm_club_type = Cells(f_i, 40) |
|
nm_chain = Cells(f_i, 19) |
|
cd_chain = fn_num2numNull(Cells(f_i, 20)) |
|
cd_Univers = Cells(f_i, 2) |
|
mag_min_price = fn_rnd_num(Cells(f_i, 23)) |
|
mag_max_price = fn_rnd_num(Cells(f_i, 25)) |
|
mag_price = fn_mag(mag_min_price, mag_max_price, mag_hd_place, nm_business) |
|
mag_hd_place = fn_rnd_num(Cells(f_i, 27)) |
|
mag_type_place = fn_mag(mag_min_price, mag_max_price, mag_hd_place, "place") |
|
vl_mag = mag_price & mag_type_place |
|
If Len(vl_mag) <> 2 Then vl_mag = Null |
|
cnt_AVG_HD = fn_rnd_num(Cells(f_i, 28)) |
|
nm_business = fn_type_business(nm_brand) |
|
vr_TypeEmotion = Cells(f_i, 41) |
|
cd_sts_dn_cln = Cells(f_i, 8) |
|
nm_Partners = Cells(f_i, 167) |
|
cd_Partner = Cells(f_i, 173) |
|
num_ev_ca = fn_num2num0(Cells(f_i, 92)) |
|
cd_idECAD = Cells(f_i, 29) |
|
EDU_ALLTIME_MSTR = Cells(f_i, 30) |
|
EDU_PY_MSTR = Cells(f_i, 31) |
|
EDU_TY_MSTR = Cells(f_i, 32) |
|
EDU_ALLTIME_CNTCT = Cells(f_i, 33) |
|
EDU_PY_CNTCT = Cells(f_i, 34) |
|
EDU_TY_CNTCT = Cells(f_i, 35) |
|
val_comKPI = Cells(f_i, 209) |
|
type_brand = fn_type_business(nm_brand) |
|
cd_brand_row = nm_brand & Cells(f_i, 1) |
|
n = 1: ar_Data(iii, n) = nm_brand: ar_nmHead(n) = "brand" |
|
n = n + 1: ar_Data(iii, n) = type_brand: ar_nmHead(n) = "bussines" |
|
n = n + 1: ar_Data(iii, n) = Cells(f_i, 1): ar_nmHead(n) = "rowTR" |
|
n = n + 1: ar_Data(iii, n) = cd_brand_row: ar_nmHead(n) = "BRAND_rowTR" |
|
If Len(cd_Univers) <> 9 Then |
|
cd_Univers = cd_brand_row |
|
Else: cd_Univers = cd_Univers |
|
n = n + 1: ar_Data(iii, n) = cd_Univers: ar_nmHead(n) = "unvCD" |
|
ar_Data(iii, n) = nm_brand & Cells(f_i, 2) |
|
ar_nmHead(n) = "BRAND_unvCD" |
|
ar_Data(iii, n) = nm_Mreg |
|
ar_Data(iii, n) = nm_Mreg_LT |
|
ar_nmHead(n) = "mreg_EXT" |
|
ar_Data(iii, n) = nm_FLSM |
|
ar_Data(iii, n) = nm_Sector |
|
ar_Data(iii, n) = nm_SREP |
|
ar_Data(iii, n) = fn_salon_name(nm_Salon, nm_Salon_addr, nm_Salon_city) |
|
ar_Data(iii, n) = nm_chain |
|
ar_nmHead(n) = "Chain_name" |
|
ar_Data(iii, n) = nm_Salon_city |
|
ar_Data(iii, n) = fn_clnt_type(nm_TypeClntRus, 1) |
|
ar_nmHead(n) = "type_SLN" |
|
ar_Data(iii, n) = fn_clnt_type(nm_TypeClntRus, 2) |
|
ar_nmHead(n) = "salon_type_eng" |
|
ar_Data(iii, n) = fn_clnt_type(nm_TypeClntRus, 3) |
|
ar_nmHead(n) = "salon_type_short_eng" |
|
ar_Data(iii, n) = fn_clnt_type(nm_TypeClntRus, 4) |
|
ar_nmHead(n) = "salon_type_chain_eng" |
|
ar_Data(iii, n) = cd_chain |
|
ar_nmHead(n) = "cd_chain" |
|
ar_Data(iii, n) = fn_getNmChainTop(nm_chain, cd_chain, nm_TypeClntRus) |
|
ar_nmHead(n) = "nm_Top10_chain" |
|
ar_Data(iii, n) = nm_club_type |
|
ar_nmHead(n) = "type_confirmed_CLUB" |
|
ar_Data(iii, n) = vr_TypeEmotion |
|
ar_nmHead(n) = "type_emotion" |
|
ar_Data(iii, n) = 1 & "." & cd_month_qnc & "." & cd_year_qnc |
|
ar_nmHead(n) = "date_CNQ_Y" |
|
ar_Data(iii, n) = cd_month_qnc |
|
ar_nmHead(n) = "date_month_num" |
|
ar_Data(iii, n) = fn_month_eng(nm_month_qnc) |
|
ar_nmHead(n) = "date_month_name" |
|
ar_Data(iii, n) = fn_getYearType(cd_ThisYear, cd_year_qnc, 1) |
|
ar_nmHead(n) = "date_year" |
|
nm_TypeGA_Y = fn_getYearType(cd_ThisYear, cd_year_qnc, 2) |
|
ar_Data(iii, n) = nm_TypeGA_Y |
|
ar_nmHead(n) = "nm_TypeGA_YEAR" |
|
ar_nmHead(n) = "type_MAG" |
|
ar_Data(iii, n) = mag_price |
|
ar_nmHead(n) = "type_MAG_PRICE" |
|
ar_Data(iii, n) = mag_type_place |
|
ar_nmHead(n) = "type_MAG_type_place" |
|
ar_Data(iii, n) = cd_sts_dn_cln |
|
ar_nmHead(n) = "status_DN_num" |
|
ar_Data(iii, n) = fn_type_active_DN(cd_sts_dn_cln) |
|
ar_nmHead(n) = "status_DN_name" |
|
ar_Data(iii, n) = fn_GetLTM(f_i, cd_ThisMonth, "avg_ca") |
|
ar_nmHead(n) = "CA_AVG_LTM" |
|
ar_Data(iii, n) = fn_GetLTM(f_i, cd_ThisMonth, "type_avg_ca") |
|
ar_nmHead(n) = "CA_AVG_LTM_name" |
|
ar_Data(iii, n) = fn_GetLTM(f_i, cd_ThisMonth, "frqOrders") |
|
ar_nmHead(n) = "frq_order_LTM" |
|
ar_Data(iii, n) = fn_num2numNull(num_ev_ca) |
|
ar_Data(iii, n) = fn_getVectoreEV(num_ev_ca) |
|
ar_nmHead(n) = "CA_ev_name" |
|
ar_Data(iii, n) = cd_idECAD |
|
ar_nmHead(n) = "EDU_id_ECAD" |
|
ar_Data(iii, n) = fn_num2numNull(EDU_ALLTIME_MSTR) |
|
ar_nmHead(n) = "EDU_ALLTIME_MSTR" |
|
ar_Data(iii, n) = fn_num2numNull(EDU_PY_MSTR) |
|
ar_nmHead(n) = "EDU_PY_MSTR" |
|
ar_Data(iii, n) = fn_num2numNull(EDU_TY_MSTR) |
|
ar_nmHead(n) = "EDU_TY_MSTR" |
|
ar_Data(iii, n) = fn_num2numNull(EDU_ALLTIME_CNTCT) |
|
ar_nmHead(n) = "EDU_ALLTIME_CNTCT" |
|
ar_Data(iii, n) = fn_num2numNull(EDU_PY_CNTCT) |
|
ar_nmHead(n) = "EDU_PY_CNTCT" |
|
ar_Data(iii, n) = fn_num2numNull(EDU_TY_CNTCT) |
|
ar_nmHead(n) = "EDU_TY_CNTCT" |
|
ar_Data(iii, n) = fn_num2numNull(mag_hd_place) |
|
ar_nmHead(n) = "type_place_HD" |
|
ar_Data(iii, n) = fn_num2numNull(cnt_AVG_HD) |
|
ar_nmHead(n) = "type_AVG_HD" |
|
ar_Data(iii, n) = val_comKPI |
|
ar_Data(iii, n) = nm_Partners |
|
ar_nmHead(n) = "nm_PRTNner" |
|
ar_Data(iii, n) = cd_Partner |
|
ar_nmHead(n) = "cd_PRTNner" |
|
'--------------------------------------------------------------------------------------------------------- |
|
'CA_MONTHLY&CUMUL&QUARTER_LOR_VAL |
|
'--------------------------------------------------------------------------------------------------------- |
|
For f_y = cd_ThisYear - 1 To cd_ThisYear |
|
nm_Y = fn_getYearType(cd_ThisYear, f_y, 2) |
|
If f_y = cd_ThisYear Then nm_period = "YTD": num_shift_clm = 12 Else nm_period = "Total": num_shift_clm = 0 |
|
val_ca = fn_getMonthlyCA(f_i, f_m, cd_ThisMonth, nm_Y, "LOR", nm_period) |
|
val_ca_cumul = val_ca_cumul + val_ca |
|
clm_ca_m = n + f_m + num_shift_clm |
|
ar_Data(iii, clm_ca_m) = fn_num2numNull(val_ca) |
|
ar_nmHead(clm_ca_m) = "CA_" & nm_Y & "_" & "M" & f_m |
|
clm_ca_ytd = n + f_m + 24 + num_shift_clm |
|
ar_Data(iii, clm_ca_ytd) = fn_num2numNull(val_ca_cumul) |
|
ar_nmHead(clm_ca_ytd) = "CA_" & nm_Y & "_" & "YTD" & f_m |
|
If f_m = cd_month_qnc Then val_ca_PY_YTD = val_ca_cumul: val_CA_MYTD_PY = val_ca |
|
If f_m = cd_month_qnc Then val_ca_TY_YTD = val_ca_cumul: val_CA_MYTD_TY = val_ca |
|
'--------------------------------------------------------------------------------------------------------- |
|
If fn_quartal(f_m) = nm_ca_quarter Then |
|
val_ca_quarter = val_ca_quarter + val_ca |
|
nm_ca_quarter = fn_quartal(f_m) |
|
ar_Data(iii, clm_ca_q) = fn_num2numNull(val_ca_quarter) |
|
ar_nmHead(clm_ca_q) = "CA_" & nm_Y & "_" & nm_ca_quarter |
|
'--------------------------------------------------------------------------------------------------------- |
|
'--------------------------------------------------------------------------------------------------------- |
|
fst_order_PRTN_TY = Empty |
|
fst_order_PRTN_PY = Empty |
|
fst_order_LOR_M_TY = Empty |
|
fst_order_LOR_M_PY = Empty |
|
fst_order_LOR_PY = fn_getMonthlyCA(f_i, cd_ThisMonth, cd_ThisMonth, "PY", "LOR", "YTD") |
|
fst_order_PRTN_PY = fn_getMonthlyCA(f_i, cd_ThisMonth, cd_ThisMonth, "PY", "PRTN", "YTD") |
|
If cd_month_qnc = cd_ThisMonth Then fst_order_LOR_M_PY = fn_getMonthlyCA(f_i, cd_ThisMonth, cd_ThisMonth, "PY", "LOR", "YTD") |
|
fst_order_LOR_TY = fn_getMonthlyCA(f_i, cd_ThisMonth, cd_ThisMonth, "TY", "LOR", "YTD") |
|
fst_order_PRTN_TY = fn_getMonthlyCA(f_i, cd_ThisMonth, cd_ThisMonth, "TY", "PRTN", "YTD") |
|
If cd_month_qnc = cd_ThisMonth Then fst_order_LOR_M_TY = fn_getMonthlyCA(f_i, cd_ThisMonth, cd_ThisMonth, "TY", "LOR", "YTD") |
|
ar_Data(iii, n) = fst_order_LOR_PY |
|
ar_nmHead(n) = "PY_CNQ_Order" |
|
ar_Data(iii, n) = fst_order_LOR_M_PY |
|
ar_nmHead(n) = "M_PY_CNQ_Order" |
|
ar_Data(iii, n) = fst_order_LOR_TY |
|
ar_nmHead(n) = "TY_CNQ_Order" |
|
ar_Data(iii, n) = fst_order_LOR_M_TY |
|
ar_nmHead(n) = "M_TY_CNQ_Order" |
|
ar_Data(iii, n) = fst_order_PRTN_PY |
|
ar_nmHead(n) = "PY_CNQ_Order_PRTN_CA" |
|
ar_Data(iii, n) = fst_order_PRTN_TY |
|
ar_nmHead(n) = "TY_CNQ_Order_PRTN_CA" |
|
'--------------------------------------------------------------------------------------------------------- |
|
'creat ca val loreal PYvsTY YTD |
|
'--------------------------------------------------------------------------------------------------------- |
|
ar_Data(iii, n) = val_ca_PY_YTD |
|
ar_nmHead(n) = "CA_PY_YTD" |
|
ar_Data(iii, n) = fn_avgCA(val_ca_PY_YTD, cd_ThisMonth) |
|
ar_nmHead(n) = "AVG_CA_PY_YTD" |
|
ar_Data(iii, n) = val_CA_MYTD_PY |
|
ar_Data(iii, n) = fn_avgCA(val_CA_MYTD_PY, cd_ThisMonth) |
|
ar_nmHead(n) = "AVG_CA_PY_M" |
|
ar_Data(iii, n) = val_ca_TY_YTD |
|
ar_nmHead(n) = "CA_TY_YTD" |
|
ar_Data(iii, n) = fn_avgCA(val_ca_TY_YTD, cd_ThisMonth) |
|
ar_nmHead(n) = "AVG_CA_TY_YTD" |
|
ar_Data(iii, n) = val_CA_MYTD_TY |
|
ar_Data(iii, n) = fn_avgCA(val_CA_MYTD_TY, cd_ThisMonth) |
|
ar_nmHead(n) = "CA_AVG_TY_M" |
|
If val_ca_PY_YTD <> 0 And val_ca_TY_YTD = 0 Then |
|
val_ca_PY_YTD_lost = val_ca_PY_YTD * -1 |
|
If val_ca_PY_YTD = 0 And val_ca_TY_YTD = 0 Then |
|
If sts_clnt_act <> 0 Then |
|
val_ca_PY_YTD_lost = val_ca_PY_YTD |
|
ar_Data(iii, n) = type_cln_react |
|
ar_nmHead(n) = "type_LOST" |
|
ar_Data(iii, n) = val_ca_PY_YTD_lost |
|
ar_nmHead(n) = "CA_LOST_PY" |
|
'--------------------------------------------------------------------------------------------------------- |
|
'--------------------------------------------------------------------------------------------------------- |
|
'If val_ca_PY_YTD > 0 Then dt_st = dt_st + 1 |
|
'If val_ca_TY_YTD > 0 Then dt_st = dt_st + 1 |
|
If cd_sts_dn_cln = 1 Then dt_st = dt_st + 1 |
|
If nm_TypeGA_Y = "PPY" Then dt_st = dt_st + 1 |
|
ar_Data(iii, n) = dt_st_nm |
|
nm_TypeGA_Y_2 = nm_TypeGA_Y & " LfL" |
|
nm_TypeGA_Y_2 = nm_TypeGA_Y & " not LfL" |
|
nm_TypeGA_Y_2 = nm_TypeGA_Y |
|
ar_Data(iii, n) = nm_TypeGA_Y_2 |
|
ar_nmHead(n) = "nm_TypeGA_YEAR_DT" |
|
'--------------------------------------------------------------------------------------------------------- |
|
val_ca_PY_YTD_dt = val_ca_PY_YTD |
|
val_ca_TY_YTD_dt = val_ca_TY_YTD |
|
val_CA_MYTD_PY_dt = val_CA_MYTD_PY |
|
val_CA_MYTD_TY_dt = val_CA_MYTD_TY |
|
ar_Data(iii, n) = val_ca_PY_YTD_dt |
|
ar_nmHead(n) = "CA_PY_LfL" |
|
ar_Data(iii, n) = val_ca_TY_YTD_dt |
|
ar_nmHead(n) = "CA_TY_LfL" |
|
ar_Data(iii, n) = val_CA_MYTD_PY_dt |
|
ar_nmHead(n) = "CA_M_PY_LfL" |
|
ar_Data(iii, n) = val_CA_MYTD_TY_dt |
|
ar_nmHead(n) = "CA_M_TY_LfL" |
|
'--------------------------------------------------------------------------------------------------------- |
|
find_nm_TypeGA_Y = "CNQ_PY" |
|
find_nm_TypeGA_Y = "CNQ_TY" |
|
If nm_TypeGA_Y = find_nm_TypeGA_Y Then |
|
val_ca_PY_YTD_GA = val_ca_PY_YTD |
|
val_ca_TY_YTD_GA = val_ca_TY_YTD |
|
val_CA_MYTD_PY_GA = val_CA_MYTD_PY |
|
val_CA_MYTD_TY_GA = val_CA_MYTD_TY |
|
If val_ca_PY_YTD_GA = 0 Then val_ca_PY_YTD_GA = Null |
|
If val_ca_TY_YTD_GA = 0 Then val_ca_TY_YTD_GA = Null |
|
If val_ca_PY_YTD_GA = 0 Then val_CA_MYTD_PY_GA = Null |
|
If val_ca_TY_YTD_GA = 0 Then val_CA_MYTD_TY_GA = Null |
|
ar_Data(iii, n) = val_ca_PY_YTD_GA |
|
ar_nmHead(n) = "CA_PY_" & find_nm_TypeGA_Y |
|
ar_Data(iii, n) = val_ca_TY_YTD_GA |
|
ar_nmHead(n) = "CA_TY_" & find_nm_TypeGA_Y |
|
ar_Data(iii, n) = val_CA_MYTD_PY_GA |
|
ar_nmHead(n) = "CA_M_PY_" & find_nm_TypeGA_Y |
|
ar_Data(iii, n) = val_CA_MYTD_TY_GA |
|
ar_nmHead(n) = "CA_M_TY_" & find_nm_TypeGA_Y |
|
'--------------------------------------------------------------------------------------------------------- |
|
If CInt(cd_year_qnc) = cd_ThisYear And cd_month_qnc <= cd_ThisMonth Then |
|
If val_ca_TY_YTD <> 0 And CInt(cd_year_qnc) <> cd_ThisYear Then |
|
nm_sts_Act_CLN = "REACTIVATED" |
|
If sumCA12M <> 0 And val_ca_TY_YTD = 0 Then |
|
nm_sts_Act_CLN = "NOT_REACTIVATED" |
|
If sumCA_PY2LTM <> 0 And sumCA12M = 0 Then |
|
ar_Data(iii, n) = nm_sts_Act_CLN |
|
ar_nmHead(n) = "Status_CLNT" |
|
'--------------------------------------------------------------------------------------------------------- |
|
'--------------------------------------------------------------------------------------------------------- |
|
nm_clsd_open_month = Empty |
|
Select Case nm_sts_Act_CLN |
|
For f_m = cd_ThisMonth To 1 Step -1 |
|
clm_m = clm_PYper_LOR_VAL + f_m - 1 |
|
If Cells(f_i, clm_m) <> 0 Then |
|
num_clsd_open_month = f_m |
|
nm_clsd_open_month = ar_month_eng(f_m - 1) |
|
nm_clsd_open_month = nmMonth |
|
nm_clsd_open_month = Empty |
|
ar_Data(iii, n) = nm_clsd_open_month |
|
ar_nmHead(n) = "Closed_Open_month" |
|
'--------------------------------------------------------------------------------------------------------- |
|
If nm_ActTR <> nm_WB Then |
|
MsgBox ("ERR" & ar_brand(f_b)) |
|
Application.DisplayAlerts = False |
|
Workbooks(nm_WB).Activate |
|
If Sheets(in_data).Visible = False Then |
|
Sheets(in_data).Visible = True |
|
'clear sheet & create head & create name OR fiil data |
|
'--------------------------------------------------------------------------------------------------------- |
|
ActiveSheet.UsedRange.Cells.ClearContents |
|
For Each n In ThisWorkbook.Names |
|
Cells(1, t) = ar_nmHead(t) |
|
ActiveWorkbook.Names.Add Name:=ar_nmHead(t), RefersTo:="=" & ActiveSheet.Name & "!" & ActiveCell.Address() |
|
ActiveSheet.Cells(start_POS, 1).Resize(end_POS - start_POS, n) = ar_Data() |
|
ActiveWorkbook.Names.Add Name:="SOURCE", RefersToR1C1:="=OFFSET(in_TR!R1C1,0,0,COUNTA(in_TR!R1C1:R65535C1),COUNTA(in_TR!R1C1:R1C255))" |
|
'ActiveWorkbook.Names("SOURCE").Comment = "" |
|
ActiveWorkbook.RefreshAll |
|
Sheets(in_data).Visible = False |
|
'--------------------------------------------------------------------------------------------------------- |
|
End Sub
|