Help with if...then

brownnr

New Member
Joined
Nov 25, 2013
Messages
18
I have code that will find and list subfolders, I need help writing an if...then...else statement that basically says if the subfolder is already listed, don't add it to list, if not, then add at end of list. I've tried all I could, but I don't think I'm putting it in the right place in the code, or something. Here is my code:

Code:
'Lists Folders '
    Worksheets(1).Activate
    Dim row As Integer
    Dim SearchFolders As Variant
    row = 3
    LookInTheFolder = "I:\projects2\Koch\58MY8900\PROCESS\2013 Work (Phase 3)\DIH_Sulfolane\Equipment"
    Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
    For Each SearchFolders In FileSystemObject.GetFolder(LookInTheFolder).SubFolders
    Cells(row, 1) = Mid(SearchFolders, InStrRev(SearchFolders, "\") + 1)
    row = row + 1
    Next SearchFolders

Thanks!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Thanks, I don't know how you can do all that just by thinking! I need more practice!

We only clean up what the bullet catchers couldn't get...:LOL:
 
Upvote 0
Thanks, I don't know how you can do all that just by thinking! I need more practice!

We only clean up what the bullet catchers couldn't get...:LOL:
here is a funny story I was working for pizza hut and just signed into the corps. And i delivered to a Army recruiter. i told him, "I just swore in and signed for the corps". He responded, "Di you think about jioning the army?".
"no, sir".
"why not?"
"all my friends are in the army"
"doesn't that tell you somthing about the army!"
"yes, sir. It's to easy to get into the army"

And the Coast guard is one i respect and wanted to join but was only going to if a buddy was signing with me. he chickened out at didn't want to join the armed forces.
 
Upvote 0
I do Co-op using Excel and VBA is a boost to me. I know your at work but when you have the time to yourself you should really check out hes videos. Helped me out alot :)
 
Upvote 0

Forum statistics

Threads
1,215,390
Messages
6,124,667
Members
449,178
Latest member
Emilou

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