Nisam razumeo ovo što si počeo, pa sam pisao novi kod. Uglavnom proverava se prva kolona po blokovima od 9 ćelija. Dodao sam posebnu funkciju kojaproverava da li je (jedan) blok ispravan
Code:
Option Explicit
Private Function CheckBlock(block As Range) As Boolean
' Check range of 9 cells
' First and last cell is empty
' Other cells are not empty
Dim cell As Variant
Dim index As Integer
Dim result As Boolean
index = 0
result = True
For Each cell In block
index = index + 1
If index = 1 Or index = 9 Then
result = result And IsEmpty(cell.Value)
Else
result = result And Not (IsEmpty(cell.Value))
End If
Next cell
CheckBlock = result
End Function
Sub CheckColumnA()
' Check column block by block
' Blocks are separated by empty cell
' Each block is 7 rows long
Const col As Integer = 1 ' Column to check
Dim stopRw As Long, rw As Long
Dim sh As Worksheet
Dim block As Range
' Get Last row
Set sh = ThisWorkbook.ActiveSheet ' Worksheet to check
stopRw = sh.Cells(sh.Rows.Count - 1, 1).End(xlUp).Row
'Loop block by block
For rw = 1 To stopRw Step 8
Set block = sh.Cells(rw, col).Resize(rowSize:=9)
If Not CheckBlock(block) Then
MsgBox "Invalid block" & sh.Cells(rw, col).Resize(rowSize:=9).Address, vbOKOnly, "Greška"
Exit For
End If
Next rw
Nije to loše Rembrante, samo što ne bi dodao još malo boje?