ignoring an instruction on a macro loop if folder already exists

Macro_

New Member
Joined
Sep 3, 2014
Messages
35
Hi all, I have this coding in my macro <!-- BEGIN TEMPLATE: bbcode_code -->

<code>If blCreateFolder Then MkDir sSaveAsPath End If</code></pre>
<!-- END TEMPLATE: bbcode_code --> When I select true on my master list the code encounters an error the second time it runs as there is already a folder created. How do I make it ignore the instruction if a folder already exists?

Appreciate any help in advance!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
First check if the folder exists. Below is a sample code:
Code:
Public Function FolderExists(foldername As String) As Boolean
'   Returns TRUE if the file exists
    If foldername = "" Then
        FolderExists = False
        Exit Function
    End If
    If Dir(foldername, vbDirectory) <> "" Then FolderExists = True _
        Else FolderExists = False
End Function
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,004
Members
449,203
Latest member
Daymo66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top