update Master_M1_Kukan

This commit is contained in:
updsv7
2026-04-15 19:15:26 +09:00
parent 60c55a40c1
commit a2ea02f36d
3 changed files with 46 additions and 107 deletions

View File

@@ -2,25 +2,21 @@
' Generic Master Common Functions
' ============================================================
Sub Generic_Master_Import(ByVal ws As Worksheet, ByVal expectedColumnCount As Long)
Dim filePath As String
Dim lines As Variant
Dim i As Long
Dim writeRow As Long
On Error GoTo ErrorHandler
' Step 1: Select CSV file
filePath = SelectCSVFile()
Dim filePath As String: filePath = SelectCSVFile()
If filePath = "" Then Exit Sub
' Step 2: Read CSV and return 2D array
lines = ReadCSVAs2DArrayStrict(filePath, expectedColumnCount, "utf-8")
Dim lines As Variant: lines = ReadCSVAs2DArrayStrict(filePath, expectedColumnCount, "utf-8")
' Step 3: Clear data rows
Call Generic_ClearDataRows(ws, 7, 3)
' Step 4: Import data
writeRow = 7
Dim i As Long
Dim writeRow As Long: writeRow = 7
For i = LBound(lines, 1) To UBound(lines, 1)
If Not isRowEmpty Then
Dim colOffset As Long
@@ -41,18 +37,12 @@ ErrorHandler:
End Sub
Sub Generic_Master_Export(ByVal ws As Worksheet, ByVal expectedColumnCount As Long, ByVal lastDataRow As Long)
Dim savePath As String
Dim r As Long
Dim rowCount As Long
Dim dataArray() As Variant
Dim dataIdx As Long
Dim j As Long
savePath = GetSaveCSVPath()
Dim savePath As String: savePath = GetSaveCSVPath()
If savePath = "" Then Exit Sub
' Count valid rows first (C column non-empty from row 7 onward)
rowCount = 0
Dim rowCount As Long: rowCount = 0
Dim r As Long
For r = 7 To lastDataRow
If Len(Trim(ws.Cells(r, 3).Value & "")) > 0 Then
rowCount = rowCount + 1
@@ -66,10 +56,12 @@ Sub Generic_Master_Export(ByVal ws As Worksheet, ByVal expectedColumnCount As Lo
End If
' Initialize 2D array: (1 To rowCount, 1 To expectedColumnCount) for columns C-I (3 to expectedColumnCount + 2)
Dim dataArray() As Variant
ReDim dataArray(1 To rowCount, 1 To expectedColumnCount)
' Fill the array
dataIdx = 0
Dim dataIdx As Long: dataIdx = 0
Dim j As Long
For r = 7 To lastDataRow
If Len(Trim(ws.Cells(r, 3).Value & "")) > 0 Then
dataIdx = dataIdx + 1