Consulting

Page 7 of 7 FirstFirst ... 5 6 7
Results 121 to 125 of 125

Thread: Combine recursive listing with excluded code

  1. #121
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    The On Error Resume Next handles the error generated if the Match() fails, so it doesn't stop


        
        i = -1
        On Error Resume Next
        i = Application.WorksheetFunction.Match(UCase(p.Name), aryFoldersToExclude, 0)  '   <<<<<<<<<<<<<<<<<<<<<<<<<
        On Error GoTo 0
        
        isFolderExcluded = (i <> -1)
    Basically it says the

    1. Make i = -1 (I use that as a check value)

    2. If there's any errors just keep on going

    3. i = index of p.name in aryFoldersToExclude or an error if not found (but continue since Resume Next 'statement')

    4. Turn off the 'Resume Next'

    5. If i <> -1 (my check value) then the folder was in the list and IsFolderExcluded = True
    5. If i = -1 (my check value) then the folder was NOT in the list and IsFolderExcluded = False

    https://docs.microsoft.com/en-us/off...rror-statement

    When there's a possibilty of getting an error, I typically will do it that way
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  2. #122
    Okay it seems like I'm just going to live with the fact that I have to turn on "break on unhandled errors" hopefully there is an answer as to why this error message occurs. Another issue is that for each parent path, in column D it still says Folder instead of parent folder, and then all subfolders inside the parent directory should say subfolder

  3. #123
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Okay it seems like I'm just going to live with the fact that I have to turn on "break on unhandled errors" hopefully there is an answer as to why this error message occurs.
    Sorry



    Capture.JPG
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #124
    Can something be done to remove the "\\?" after pressing the button 1 so that the search returns a clean path ?

  5. #125
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Add the marked line to sub listData



        'final format
        wsOut.Columns(colPath).Replace What:="\\?\", Replacement:=vbNullString, LookAt:=xlPart
        wsOut.Columns(colName).HorizontalAlignment = xlLeft
        wsOut.Columns(colCreated).NumberFormat = "m/dd/yyyy"
        wsOut.Columns(colModified).NumberFormat = "m/dd/yyyy"
        wsOut.Columns(colSize).NumberFormat = "#,##0"
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •