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,96 @@
Sales No. Date Agent Name Team Selling Price Commision(%)
1 6/1/2023 Eason A 4432 35%
2 6/1/2023 Candy A 12483 20%
3 10/1/2023 Henry B 918 30%
4 11/1/2023 Eason A 13224 20%
5 12/1/2023 Irene B 10986 35%
```prompt
1. i need a excel function that will open a excel file named `D:\_workspace\carousell-comission-playlist\jimmycheung93\task4\_poc\parse_xlsx\parse_Agent_Sales\Agent_Sales.xlsx`
2. check if sheet named `Sheet1` exist
2.1 if not exist exit function with error
4. read all rows until table end
4.1 check first cell and exit for loop if first cell is empty
5. print the content of cell using debug.print
99. then close and save that excel file
thanks
```
```vb
Sub OpenAndReadAgentSalesWorkbook()
Dim wb As Workbook
' Set the path of the workbook to open
sPath = "D:\_workspace\carousell-comission-playlist\jimmycheung93\task4\_poc\parse_xlsx\parse_Agent_Sales\Agent_Sales.xlsx"
' Try to open the workbook
On Error Resume Next
Set wb = Workbooks.Open(sPath)
On Error GoTo 0
' Check if the opening was successful
If wb Is Nothing Then
MsgBox "Could not open workbook at " & sPath, vbCritical, "Error"
Exit Sub
End If
' Look for Sheet1 and stop execution if it doesn't exist
If Not wb.Sheets("Sheet1") Is Nothing Then
' Read data from Sheet1
For Each rw In wb.Sheets("Sheet1").UsedRange.Rows
' Check if first cell is empty
If Trim(rw.Cells(1)) <> "" Then
' Print value of first column of current row to immediate window
Debug.Print rw.Cells(1).Value
Debug.Print rw.Cells(2).Value
Debug.Print rw.Cells(3).Value
Debug.Print rw.Cells(4).Value
Debug.Print rw.Cells(5).Value
Debug.Print rw.Cells(6).Value
Else
' First cell in current row is empty, so break the loop
Exit For
End If
Next rw
Else
MsgBox """Sheet1"" does not exist in workbook at " & sPath, vbExclamation, "Warning"
Exit Sub
End If
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"

View File

@@ -0,0 +1,96 @@
Sales No. Date Agent Name Team Selling Price Commision(%)
1 6/1/2023 Eason A 4432 35%
2 6/1/2023 Candy A 12483 20%
3 10/1/2023 Henry B 918 30%
4 11/1/2023 Eason A 13224 20%
5 12/1/2023 Irene B 10986 35%
```prompt
1. i need a excel function that will open a excel file named `D:\_workspace\carousell-comission-playlist\jimmycheung93\task4\_poc\parse_xlsx\parse_Agent_Sales\Agent_Sales.xlsx`
2. check if sheet named `Sheet1` exist
2.1 if not exist exit function with error
4. read all rows until table end
4.1 check first cell and exit for loop if first cell is empty
5. print the content of cell using debug.print
99. then close and save that excel file
thanks
```
```vb
Sub OpenAndReadAgentSalesWorkbook()
Dim wb As Workbook
' Set the path of the workbook to open
sPath = "D:\_workspace\carousell-comission-playlist\jimmycheung93\task4\_poc\parse_xlsx\parse_Agent_Working_Performance\Agent_Working_Performance.xlsx"
' Try to open the workbook
On Error Resume Next
Set wb = Workbooks.Open(sPath)
On Error GoTo 0
' Check if the opening was successful
If wb Is Nothing Then
MsgBox "Could not open workbook at " & sPath, vbCritical, "Error"
Exit Sub
End If
' Look for Sheet1 and stop execution if it doesn't exist
If Not wb.Sheets("Sheet1") Is Nothing Then
' Read data from Sheet1
For Each rw In wb.Sheets("Sheet1").UsedRange.Rows
' Check if first cell is empty
If Trim(rw.Cells(1)) <> "" Then
' Print value of first column of current row to immediate window
Debug.Print rw.Cells(1).Value
Debug.Print rw.Cells(2).Value
Debug.Print rw.Cells(3).Value
Debug.Print rw.Cells(4).Value
Debug.Print rw.Cells(5).Value
Debug.Print rw.Cells(6).Value
Else
' First cell in current row is empty, so break the loop
Exit For
End If
Next rw
Else
MsgBox """Sheet1"" does not exist in workbook at " & sPath, vbExclamation, "Warning"
Exit Sub
End If
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"

View File

@@ -0,0 +1,96 @@
Sales No. Date Agent Name Team Selling Price Commision(%)
1 6/1/2023 Eason A 4432 35%
2 6/1/2023 Candy A 12483 20%
3 10/1/2023 Henry B 918 30%
4 11/1/2023 Eason A 13224 20%
5 12/1/2023 Irene B 10986 35%
```prompt
1. i need a excel function that will open a excel file named `D:\_workspace\carousell-comission-playlist\jimmycheung93\task4\_poc\parse_xlsx\parse_Agent_Sales\Agent_Sales.xlsx`
2. check if sheet named `Sheet1` exist
2.1 if not exist exit function with error
4. read all rows until table end
4.1 check first cell and exit for loop if first cell is empty
5. print the content of cell using debug.print
99. then close and save that excel file
thanks
```
```vb
Sub OpenAndReadProductSalesWorkbook()
Dim wb As Workbook
' Set the path of the workbook to open
sPath = "D:\_workspace\carousell-comission-playlist\jimmycheung93\task4\_poc\parse_xlsx\parse_Product_Sales\Product_Sales.xlsx"
' Try to open the workbook
On Error Resume Next
Set wb = Workbooks.Open(sPath)
On Error GoTo 0
' Check if the opening was successful
If wb Is Nothing Then
MsgBox "Could not open workbook at " & sPath, vbCritical, "Error"
Exit Sub
End If
' Look for Sheet1 and stop execution if it doesn't exist
If Not wb.Sheets("Sheet1") Is Nothing Then
' Read data from Sheet1
For Each rw In wb.Sheets("Sheet1").UsedRange.Rows
' Check if first cell is empty
If Trim(rw.Cells(1)) <> "" Then
' Print value of first column of current row to immediate window
Debug.Print rw.Cells(1).Value
Debug.Print rw.Cells(2).Value
Debug.Print rw.Cells(3).Value
Debug.Print rw.Cells(4).Value
Debug.Print rw.Cells(5).Value
Debug.Print rw.Cells(6).Value
Else
' First cell in current row is empty, so break the loop
Exit For
End If
Next rw
Else
MsgBox """Sheet1"" does not exist in workbook at " & sPath, vbExclamation, "Warning"
Exit Sub
End If
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"