update Master_M1_Kukan
This commit is contained in:
@@ -1,12 +1,6 @@
|
||||
' ============================================================
|
||||
' Generic Master Common Functions
|
||||
' ============================================================
|
||||
|
||||
Sub Generic_Master_ClearRowData(ByVal ws As Worksheet, ByVal rowNum As Long)
|
||||
ws.Range(ws.Cells(rowNum, 4), ws.Cells(rowNum, 15)).ClearContents
|
||||
ws.Cells(rowNum, 2).ClearContents
|
||||
End Sub
|
||||
|
||||
Sub Generic_Master_Import(ByVal ws As Worksheet, ByVal expectedColumnCount As Long)
|
||||
Dim filePath As String
|
||||
Dim lines As Variant
|
||||
@@ -23,7 +17,7 @@ Sub Generic_Master_Import(ByVal ws As Worksheet, ByVal expectedColumnCount As Lo
|
||||
lines = ReadCSVAs2DArrayStrict(filePath, expectedColumnCount, "utf-8")
|
||||
|
||||
' Step 3: Clear data rows
|
||||
Call ClearDataRows(ws, 7, 3)
|
||||
Call Generic_ClearDataRows(ws, 7, 3)
|
||||
|
||||
' Step 4: Import data
|
||||
writeRow = 7
|
||||
@@ -89,4 +83,13 @@ Sub Generic_Master_Export(ByVal ws As Worksheet, ByVal expectedColumnCount As Lo
|
||||
Call WriteCSVFromArray(savePath, dataArray, "utf-8", True)
|
||||
|
||||
MsgBox "CSV export completed. Total data rows: " & rowCount, vbInformation
|
||||
End Sub
|
||||
|
||||
Sub Generic_ClearDataRows(ByVal ws As Worksheet, ByVal startRow As Long, ByVal columnNum As Long)
|
||||
Dim lastRow As Long
|
||||
lastRow = ws.Cells(ws.Rows.Count, columnNum).End(xlUp).Row
|
||||
|
||||
If lastRow >= startRow Then
|
||||
ws.Range(ws.Cells(startRow, 1), ws.Cells(lastRow, 20)).ClearContents
|
||||
End If
|
||||
End Sub
|
||||
@@ -132,14 +132,22 @@ Function GetLastDataRowInRange(ws As Worksheet, ByVal startCol As Long, ByVal en
|
||||
GetLastDataRowInRange = maxRow
|
||||
End Function
|
||||
|
||||
Sub ClearDataRows(ByVal ws As Worksheet, ByVal startRow As Long, ByVal columnNum As Long)
|
||||
Dim lastRow As Long
|
||||
lastRow = ws.Cells(ws.Rows.Count, columnNum).End(xlUp).Row
|
||||
|
||||
If lastRow >= startRow Then
|
||||
ws.Range(ws.Cells(startRow, 1), ws.Cells(lastRow, 20)).ClearContents
|
||||
Function ClearDataRow(ByVal ws As Worksheet, ByVal startCol As Long, ByVal endCol As Long, ByVal rowRow As Long, Optional ByVal errorCol As Long = 2)
|
||||
If rowRow >= 7 Then
|
||||
Dim clearRange As Range: Set clearRange = ws.Range(ws.Cells(rowRow, startCol), ws.Cells(rowRow, endCol))
|
||||
clearRange.ClearContents
|
||||
clearRange.Interior.Color = vbWhite
|
||||
ws.Range(ws.Cells(rowRow, errorCol), ws.Cells(rowRow, errorCol)).ClearContents
|
||||
End If
|
||||
End Sub
|
||||
End Function
|
||||
|
||||
Function ClearDataRows(ByVal ws As Worksheet, ByVal startCol As Long, ByVal endCol As Long, Optional ByVal startRow As Long = 7)
|
||||
Dim lastDataRow As Long: lastDataRow = GetLastDataRowInRange(ws, startCol, endCol, startRow)
|
||||
|
||||
If lastDataRow >= startRow Then
|
||||
ws.Range(ws.Cells(startRow, startCol), ws.Cells(lastDataRow, endCol)).ClearContents
|
||||
End If
|
||||
End Function
|
||||
|
||||
Sub SortDataRows(Optional ByVal sortColumn As Long = 3)
|
||||
Dim ws As Worksheet
|
||||
|
||||
Reference in New Issue
Block a user