next version

This commit is contained in:
updsv7
2026-04-18 21:42:00 +09:00
parent 7c487cba0b
commit 4a1be61150
26 changed files with 1101 additions and 769 deletions

View File

@@ -0,0 +1,112 @@
Attribute VB_Name = "Common_Button"
Option Explicit
' ============================================================
' Module Name: Common_Button
' Module Desc: Common_Button
' Module Methods:
' - Import
' ============================================================
Sub CSV_Import_Button()
DO_CSV_Import ActiveSheet
End Sub
Sub Validation_Button()
Do_Validation ActiveSheet
End Sub
Sub CSV_Export_Button()
CSV_Import ActiveSheet
End Sub
Sub Do_Sort_Button()
Do_Sort ActiveSheet
End Sub
Sub Do_Filter_Button()
Do_Filter ActiveSheet
End Sub
Sub Do_Fit_Button()
Do_Fit ActiveSheet
End Sub
Private Sub DO_CSV_Import(ws As Excel.Worksheet)
Dim macroName As String
macroName = ws.CodeName & ".Import"
If Not ProcedureExists(ws.CodeName, "Import") Then
MsgBox "worksheet """ & ws.name & """ unimplement methods", vbExclamation
Exit Sub
End If
On Error GoTo ErrorHandler
Application.Run macroName, ws
Exit Sub
ErrorHandler:
MsgBox "error" & Err.Description, vbCritical
End Sub
Private Sub Do_Validation(ws As Excel.Worksheet)
If dataRangeDict Is Nothing Then Call RefreshDataRangeDict
Dim dataRange As Variant: dataRange = dataRangeDict(ws.CodeName)
' step1. confirm Validate Sub
Dim validate As String
validate = ws.CodeName & ".Validate"
If Not ProcedureExists(ws.CodeName, "Validate") Then
MsgBox "worksheet """ & ws.name & """ unimplement methods", vbExclamation
Exit Sub
End If
' step2. confirm data range
Dim lastDataRow As Long, r As Long, errorCount As Long
lastDataRow = GetLastDataRowInRange(ws)
Dim startRow As Long: startRow = dataRange(3)
Dim errorCol As Long: errorCol = ws.Range(dataRange(2) & "1").Column
If lastDataRow < startRow Then
MsgBox "No data found.", vbExclamation
Exit Sub
End If
For r = startRow To lastDataRow
On Error GoTo ErrorHandler
Application.Run validate, ws, r, lastDataRow
If Trim(ws.Cells(r, errorCol).Value) <> "" Then
errorCount = errorCount + 1
End If
Next r
' === Refresh ws cache after validation passes ===
If errorCount = 0 Then
Dim cacheMethodName As String: cacheMethodName = dataRange(5)
If
'' TODO
Call RefreshM1Cache
End If
MsgBox "Validation complete. Errors: " & errorCount, vbInformation
ErrorHandler:
MsgBox "error" & Err.Description, vbCritical
End Sub
Private Function ProcedureExists(moduleName As String, procName As String) As Boolean
Dim VBProj As Object, VBComp As Object, CodeMod As Object
Set VBProj = ThisWorkbook.VBProject
Set VBComp = VBProj.VBComponents(moduleName)
If Not VBComp Is Nothing Then
Set CodeMod = VBComp.CodeModule
ProcedureExists = (CodeMod.ProcStartLine(procName, 0) > 0)
End If
End Function