| 
    
     |  | Option Explicit 
 Public Sub Sample()
 
 Dim i As Long
 Dim lngStart As Long
 Dim lngRowEnd As Long
 Dim vntResult As Variant
 
 '先頭行位置
 lngStart = 1
 '最終行取得
 lngRowEnd = Cells(Rows.Count, "A").End(xlUp).Row
 
 For i = lngStart + 1 To lngRowEnd
 If IsEmpty(Cells(i, "B").Value) Then
 'ブランクセル先頭なら
 If IsEmpty(vntResult) Then
 vntResult = Cells(i - 1, "B").Value
 End If
 vntResult = vntResult + Cells(i, "B").Value
 Else
 'ブランクセル最終の下なら
 If Not IsEmpty(vntResult) Then
 MsgBox "B列と比較する値は" & vntResult
 vntResult = Empty
 End If
 End If
 Next i
 
 'Loop最終行がブランクだった場合
 If Not IsEmpty(vntResult) Then
 MsgBox "B列と比較する値は" & vntResult
 End If
 
 End Sub
 
 |  |