Skills/Excel VBA

카운터 로직

섬그늘 2008. 11. 13. 14:32

아래와 같이 짜 봤으나 이상하게 실행속도가 느림. 향후 점검용...(2008.02.07)

 

Sub 합계검색()
'
' 합계검색 Macro
'
' Keyboard Shortcut: Ctrl+Shift+T

Dim i, j, k, l, cr, nrow, ncol, myAns, srow, scol, strt As Byte
nrow = 16: ncol = 3
srow = 2: scol = 1
ReDim A(nrow, ncol) As Long
ReDim B(ncol) As Long
ReDim c(ncol) As Byte

'Reading
For i = 0 To ncol
For j = 0 To nrow
A(j, i) = Cells(j + srow, i + scol)
Next j
Next i
Cells(3, 6) = Time() '시작 시간 기록

For k = 0 To 100000
cr = 1

'Counter
For i = 0 To ncol
Cells(2, 6 + i) = c(i)
Next i
l = ncol
Cup:
If c(l) < nrow Then
c(l) = c(l) + 1: GoTo Cnext
ElseIf l = 0 Then GoTo EOP 'end로 감
Else: For i = l To ncol: c(i) = 0: Next i: l = l - 1: GoTo Cup
End If
Cnext:
Next k

EOP:
Cells(4, 6) = Time() '끝 시간 기록
End Sub