空白でないセルの最初と最後の行が必要です。 私の最後の行は正常に動作し、最初の行はバストです。提案は高く評価されました。VBAはデータの最初と最後の行を特定します
Sub idDataRange()
Dim firstRow As Long
Dim lastRow As Long
Sheets("fileNames").Select
' this has been adapted from a Stack overflow answer. lastRow unedited
' first row I changed Up to Down = NOT the solution!
With ActiveSheet
firstRow = .Range("B" & .Rows.Count).End(xlDown).row
lastRow = .Range("B" & .Rows.Count).End(xlUp).row
End With
MsgBox "the first row is " & firstRow
MsgBox "last row is " & lastRow
End Sub
チャームのように機能するようになりました。私は離れて試してみる必要があります。 – m4sterbunny