update Generic Master bas4
This commit is contained in:
51
src/thisWorkbook/Master_O1_address.bas
Normal file
51
src/thisWorkbook/Master_O1_address.bas
Normal file
@@ -0,0 +1,51 @@
|
||||
Sub O1_Import()
|
||||
Dim filePath As String
|
||||
Dim lines As Variant
|
||||
Dim i As Long
|
||||
Dim writeRow As Long
|
||||
|
||||
Set ws = Me
|
||||
|
||||
On Error GoTo ErrorHandler
|
||||
|
||||
' Step 1: Select CSV file
|
||||
filePath = SelectCSVFile()
|
||||
If filePath = "" Then Exit Sub
|
||||
|
||||
' Step 2: Read CSV and return 2D array
|
||||
lines = ReadCSVAs2DArrayStrict(filePath, 4, "shift-jis", True)
|
||||
|
||||
' Step 3: Clear data rows
|
||||
Call ClearDataRows(ws, 7, 3)
|
||||
|
||||
' Step 4: Import data
|
||||
writeRow = 7
|
||||
For i = LBound(lines, 1) To UBound(lines, 1)
|
||||
If Not isRowEmpty Then
|
||||
Dim colOffset As Long
|
||||
For colOffset = 1 To 4
|
||||
ws.Cells(writeRow, 2 + colOffset).Value = CleanCSVField(CStr(lines(i, colOffset)))
|
||||
Next colOffset
|
||||
writeRow = writeRow + 1
|
||||
End If
|
||||
Next i
|
||||
|
||||
MsgBox writeRow - 7 & " rows imported.", vbInformation
|
||||
|
||||
Exit Sub
|
||||
|
||||
ErrorHandler:
|
||||
MsgBox "Import fails:" & vbCrLf & Err.Description, vbCritical
|
||||
End Sub
|
||||
|
||||
Sub O1_SortDataRowsByC()
|
||||
Call SortDataRows(3)
|
||||
End Sub
|
||||
|
||||
Sub O1_ToggleAutoFilter()
|
||||
Call ToggleAutoFilter(6)
|
||||
End Sub
|
||||
|
||||
Sub O1_AutoFitColumnWidth()
|
||||
Call AutoFitColumnWidth(3, 5)
|
||||
End Sub
|
||||
Reference in New Issue
Block a user