This commit is contained in:
louiscklaw
2025-01-31 21:36:48 +08:00
parent 8ee1ccbebc
commit 2e592cb561
248 changed files with 11958 additions and 0 deletions

View File

@@ -0,0 +1,140 @@
Case Persistency
Name No of new case No. of collpased case Case Persistency
Alex 46 14 53.33%
Ben 20 14 17.65%
Candy 49 11 63.33%
Danny 55 9 71.88%
Eason 49 11 63.33%
Filex 70 27 44.33%
Gary 41 3 86.36%
Henry 44 1 95.56%
Irene 60 17 55.84%
Jenny 59 16 57.33%
Team A total 219 59 57.55%
Team B Total 274 64 62.13%
```prompt
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
```
```vb
Sub NoOfCases()
Const FILE_PATH As String = "D:\_workspace\carousell-comission-playlist\jimmycheung93\task4\_poc\No of cases\helloworld.xlsx"
Const TOP_ROW As Long = 1
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("No. of cases")
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 = "No. of cases"
Else
' Empty the entire sheet
ws.UsedRange.ClearContents
End If
' Write month names
Set startCell = ws.Range("A1")
tempArray = Array("Case Persistency")
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("Name","No of new case","No. of collpased case","Case Persistency")
For i = LBound(tempArray) To UBound(tempArray)
startCell.Offset(0, i).Value = tempArray(i)
Next i
' Write month names
Set startCell = ws.Range("A3")
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("A14")
tempArray = Array("Team A total", "Team B Total")
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
```
'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"

Binary file not shown.

Binary file not shown.