나눔터  
  HOME > 나눔터 > 묻고답하기 > 엑셀
엑셀
엑셀에 대한 질문과 답변을 올려주세요. 단, 취지에 맞지 않는 글은 운영자가 삭제합니다.
 "000 님, 도와주세요", "부탁 드립니다.", "급합니다!" 등과 같이 막연한 제목을 달지 말아주세요.
[필독] 빠르고 정확한 답변을 얻는 16가지 Tip !
[필독] 저작권법 개정에 따른 이용안내
작성자:  

 hyh (hyh57)

추천:  2
파일:     재귀함수.xlsm (14.4KB) 조회:  1971
제목:   재귀함수 조건에 맞을때 종료 방법
     
  * 답변하시는 분들께 도움이 되도록 자신의 환경을 아래 항목 옆에 기재해 주세요.

 - 엑셀 버전(,2007):

* 아래줄에 질문을 작성하세요 >>
아래 재귀 함수가 조건에 맞으면 종료 하고 싶어요
exit sub  도 안되고
exit loop도 안됨니다
방법이 없나요?

Sub LoopFile(strFilter, folderPath)    'Optional strFilter As String

Dim Filename As String, dirName As String
Dim fullFilePath As String
Dim numFolders As Long
Dim folders() As String
'Dim strFilter As String
Dim i As Long
'On Error Resume Next
If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"
'strFilter = "*.*"

Filename = Dir(folderPath & strFilter)
Debug.Print folderPath

dirName = Dir(folderPath, vbDirectory)

Do While dirName <> ""
    If Left(dirName, 1) <> "." Then
        If (GetAttr(folderPath & dirName) And vbDirectory) = vbDirectory Then
            ReDim Preserve folders(0 To numFolders) As String
            folders(numFolders) = folderPath & dirName
            numFolders = numFolders + 1
        Else
            If InStr(dirName, strFilter) >= 1 Then

              여기서 조건에 맞으니 전프로그램 종요 하고 싶어요
            End If
        End If
    End If
    dirName = Dir()

Loop

For i = 0 To numFolders - 1
    LoopFile strFilter, folders(i)
Next i

End Sub


 
[불량 게시물 신고]  
        
  

작성일 : 2020-05-19(15:42)
최종수정일 : 2020-05-19(15:42)
 


 ◎ 관련글

  제 목   작성자   날짜
재귀함수 조건에 맞을때 종료 방법 hyh 2020-05-19
[RE]재귀함수?조건에?맞을때?종료?방법 slgi 2020-05-25
[RE]재귀함수?조건에?맞을때?종료?방법 hyh 2020-06-05