Files
004_comission/jimmycheung93/task4/_poc/Agent performance analysis/Agent performance analysis prompt.md
louiscklaw 2e592cb561 update,
2025-01-31 21:36:48 +08:00

7.9 KiB

January Feburary March April May June July Augest September October November December Alex 11329 0 9088.2 9954 16537.2 1166.55 1269.2 1324 1767.2 3950.3 0 16653.2 Ben 0 7321.6 1450.5 1931.2 5299.9 10666.8 0 373.5 0 0 0 0 Candy 27546.75 0 0 0 0 7993.8 12959.4 8533.35 4377.6 31058 724.5 16883.1 Danny 7357 47805 13873.75 9885.85 9548 11063.8 152.1 4791.2 7437.5 16389.75 147.9 499.5 Eason 2882.4 12648.75 17099.95 5186.4 15248.8 3102.4 30012 5036 0 67.5 8676.9 0 Filex 5830.8 46820.5 31655.7 4291.8 9886.4 1152 0 8010.8 11494.15 1373.7 11113.2 63684.8 Gary 0 17772.8 26407.05 36516.8 678.7 648 0 7515.25 1578.45 1116 73.5 39.5 Henry 0 0 41.5 18345.3 23600.3 1238.4 538.4 19172.55 0 550.8 21873.6 579.9 Irene 0 32649.9 0 12510.6 27206.7 7856.6 2204.85 24630.55 847.8 9049.5 681.3 62511.75 Jenny 15994.8 20370.2 0 6692 4528.4 0 2186.35 0 23746.5 16805.6 4193 9749

Total 70940.75 185388.75 99616.65 105313.95 112534.4 44888.35 49322.3 79387.2 51249.2 80361.15 47483.9 170600.75

Team A total 49115.15 67775.35 41512.4 26957.45 46633.9 33993.35 44392.7 20058.05 13582.3 51465.55 9549.3 34035.8 Team B Total 21825.6 117613.4 58104.25 78356.5 65900.5 10895 4929.6 59329.15 37666.9 28895.6 37934.6 136564.95 Team A Quartely 158402.9 107584.7 78033.05 95050.65 Team B Quartely 197543.25 155152 101925.65 203395.15

Rank for Each Month January February March April May June 1 Candy 8987.85 Danny 14903.5 Filex 10551.9 Gary 10323.2 Irene 11178 Danny 4942.2 2 Alex 5441.5 Filex 14005.8 Gary 9802.45 Henry 5876.7 Alex 6870 Irene 3928.3 3 Jenny 5358.6 Irene 8218.5 Eason 5239.85 Irene 5267.1 Henry 6623.8 Ben 3555.6 4 Danny 3678.5 Jenny 6956.3 Danny 3529.75 Danny 4926.85 Eason 3875.2 Candy 2664.6 5 Filex 2996.4 Eason 5418.45 Alex 3029.4 Alex 3380.4 Ben 3011.6 Eason 1551.2

July August September October November December 1 Eason 7704.6 Henry 7242.35 Jenny 9490.2 Candy 8743.2 Henry 5468.4 Irene 18256.05 2 Candy 4339.8 Irene 6562.15 Filex 4535.35 Danny 5505.75 Filex 3704.4 Filex 16776.4 3 Irene 2204.85 Filex 4005.4 Danny 2949.8 Irene 4360.5 Eason 2892.3 Candy 5627.7 4 Jenny 2085.85 Gary 3149.35 Candy 1836 Jenny 4201.4 Jenny 1241.2 Alex 4661.8 5 Alex 1269.2 Candy 2844.45 Gary 1578.45 Alex 2773.1 Irene 681.3 Jenny 2540



1. i need a excel function that will open a excel file named `D:\_workspace\carousell-comission-playlist\jimmycheung93\task4\_poc\Sales Analysis Product Category\helloworld.xlsx`
2. check if sheet named `Sales Analysis Product Category` exist
  2.1 if not exist create a sheet named `Sales Analysis Product Category`
  2.2 if exist, empty the whole sheet
4. write Month first row as header of table
5. write Quarter first row as header of table
6. write Product Category first row as header of table
7. write Selling unit first row as header of table
8. write Monthly Sales first row as header of table
9. write Quartely sales first row as header of table
10. write commission first row as header of table
11. write Monthly Margin first row as header of table
12. write Quaterly Margin first row as header of table
13. write Quaterly Commission first row as header of table
14. write "January" at "A2"
15. write "Feburary" at "A3"
16. write "March" at "A4"
17. write "April" at "A5"
18. write "May" at "A6"
19. write "June" at "A7"
20. write "July" at "A8"
21. write "Augest" at "A9"
22. write "September" at "A10"
23. write "October" at "A11"
24. write "November" at "A12"
25. write "December" at "A13"

99. then close and save that excel file

thanks
Sub AgentPerformanceAnalysisComm()
    Const FILE_PATH As String = "D:\_workspace\carousell-comission-playlist\jimmycheung93\task4\_poc\Agent performance analysis\helloworld.xlsx"
    Const TOP_ROW As Long = 1
    Const START_CELL As String = "A2"
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim startCell As Range
    Dim tempArray() as Variant
    Dim i As Long

    ' Open the workbook
    Set wb = Workbooks.Open(FILE_PATH)

    ' Check if the sheet exists
    On Error Resume Next
    Set ws = wb.Sheets("Agent performance analysis(Comm")
    On Error GoTo 0

    ' If not found, create a new sheet
    If ws Is Nothing Then
        Set ws = wb.Sheets.Add(After:=wb.Sheets(wb.Sheets.Count))
        ws.Name = "Agent performance analysis(Comm"
    Else
        ' Empty the entire sheet
        ws.UsedRange.ClearContents
    End If

    ' Write month names
    Set startCell = ws.Range("B1")
    tempArray = Array("January","Feburary","March","April","May","June","July","Augest","September","October","November","December")
    For i = LBound(tempArray) To UBound(tempArray)
        startCell.Offset(0, i).Value = tempArray(i)
    Next i

    ' Write month names
    Set startCell = ws.Range("A2")
    tempArray = Array("Alex","Ben","Candy","Danny","Eason","Filex","Gary","Henry","Irene","Jenny")
    For i = LBound(tempArray) To UBound(tempArray)
        startCell.Offset(i, 0).Value = tempArray(i)
    Next i

    ' Write month names
    Set startCell = ws.Range("A16")
    Dim tempArray() As Variant
    tempArray = Array("Total","","Team A total", "Team B Total", "Team A Quartely", "Team B Quartely")
    Dim i As Long
    For i = LBound(tempArray) To UBound(tempArray)
        startCell.Offset(i, 0).Value = tempArray(i)
    Next i


    ' Save and close the workbook
    wb.Close SaveChanges:=True
End Sub
Sub AgentPerformanceAnalysisCommRankForEachMonth()
    Const FILE_PATH As String = "D:\_workspace\carousell-comission-playlist\jimmycheung93\task4\_poc\Agent performance analysis\helloworld.xlsx"
    Const TOP_ROW As Long = 21
    Const START_CELL As String = "A2"
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim startCell As Range
    Dim i As Long
    Dim tempArray() as Variant

    ' Open the workbook
    Set wb = Workbooks.Open(FILE_PATH)

    ' Check if the sheet exists
    On Error Resume Next
    Set ws = wb.Sheets("Agent performance analysis(Comm")
    On Error GoTo 0

    ' If not found, create a new sheet
    If ws Is Nothing Then
        Set ws = wb.Sheets.Add(After:=wb.Sheets(wb.Sheets.Count))
        ws.Name = "Agent performance analysis(Comm"
    Else
        ' Empty the entire sheet
        ' ws.UsedRange.ClearContents
    End If

    ' Write headers
    With ws.Rows(TOP_ROW)
        .Cells(1).Value = "Rank for Each Month"
    End With

    ' Write month names
    Set startCell = ws.Range("A23")
    tempArray = Array("1","2","3","4","5")
    For i = LBound(tempArray) To UBound(tempArray)
        startCell.Offset(i, 0).Value = i+1
    Next i

    Set startCell = ws.Range("B22")
    tempArray = Array("January","Feburary","March","April","May","June")
    For i = LBound(tempArray) To UBound(tempArray)
        startCell.Offset(0, i*2).Value = tempArray(i)
    Next i

    Set startCell = ws.Range("A30")
    tempArray = Array("1","2","3","4","5")
    For i = LBound(tempArray) To UBound(tempArray)
        startCell.Offset(i, 0).Value = i+1
    Next i

    Set startCell = ws.Range("B29")
    tempArray = Array("July","Augest","September","October","November","December")
    For i = LBound(tempArray) To UBound(tempArray)
        startCell.Offset(0, i*2).Value = tempArray(i)
    Next i

    ' Save and close the workbook
    ' wb.Close SaveChanges:=True
End Sub

'column SALES_ANALYSIS_COL_MONTH = "A" SALES_ANALYSIS_COL_QUARTER = "B" SALES_ANALYSIS_COL_PRODUCT_CATEGORY = "C" SALES_ANALYSIS_COL_SELLING_UNIT = "D" SALES_ANALYSIS_COL_MONTHLY_SALES = "E" SALES_ANALYSIS_COL_QUARTELY_SALES = "F" SALES_ANALYSIS_COL_COMMISSION = "G" SALES_ANALYSIS_COL_MONTHLY_MARGIN = "H" SALES_ANALYSIS_COL_QUATERLY_MARGIN = "I" SALES_ANALYSIS_COL_QUATERLY_COMMISSION_ = "J"

'row SALES_ANALYSIS_ROW_JANUARY = "2" SALES_ANALYSIS_ROW_FEBURARY = "3" SALES_ANALYSIS_ROW_MARCH = "4" SALES_ANALYSIS_ROW_APRIL = "5" SALES_ANALYSIS_ROW_MAY = "6" SALES_ANALYSIS_ROW_JUNE = "7" SALES_ANALYSIS_ROW_JULY = "8" SALES_ANALYSIS_ROW_AUGEST = "9" SALES_ANALYSIS_ROW_SEPTEMBER = "10" SALES_ANALYSIS_ROW_OCTOBER = "11" SALES_ANALYSIS_ROW_NOVEMBER = "12" SALES_ANALYSIS_ROW_DECEMBER = "13"