Fix lastDataRow calculation

This commit is contained in:
updsv7
2026-04-13 14:45:32 +09:00
parent 6a65a4504e
commit 6c07b145b2

View File

@@ -368,8 +368,15 @@ Sub ExportMasterDetailData()
Dim ws As Worksheet
Set ws = ActiveSheet
' Find actual last row with data
Dim lastDataRow As Long
lastDataRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row
Dim r As Long
lastDataRow = 6
For r = 7 To 10000
If Trim(ws.Cells(r, 3).Value) <> "" Then
lastDataRow = r
End If
Next r
If lastDataRow < 7 Then
MsgBox "No data rows to output.", vbExclamation