엑셀 vba continue_cu_or_ncu 함수
Function continue_cu_or_ncu(rng As Range, chul As String)
Dim cnt, maxx
Dim oldv
Dim c, r
Dim i, ils
maxx = 0
cnt = 0
If chul = "mcu" Then
oldv = 0
Else
oldv = 1
End If
For Each target In rng
If chul = "mcu" Then
If target.Value = 0 Or target.Value = "" Then
cnt = cnt + 1
If oldv <> 0 Or oldv <> "" Then
If maxx < cnt Then
maxx = cnt
End If
End If
Else
If maxx < cnt Then
maxx = cnt
End If
cnt = 0
End If
Else
If target.Value > 0 Then
cnt = cnt + 1
If oldv > 0 Then
If maxx < cnt Then
maxx = cnt
End If
End If
Else
If maxx < cnt Then
maxx = cnt
End If
cnt = 0
End If
End If
oldv = target.Value
Next
continue_cu_or_ncu = maxx
End Function
.