File system objects VBA

%3CLINGO-SUB%20id%3D%22lingo-sub-3404718%22%20slang%3D%22en-US%22%3EFile%20system%20objects%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3404718%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20I%20am%20looping%20through%20a%20sub%20folder%20and%20I'd%20like%20to%20change%20folder%20path%20like%3A%3C%2FP%3E%3CP%3EDim%20fol%20As%20Scripting.folder%3C%2FP%3E%3CP%3E'if%20Sheet1.Range(%22f%22%20%26amp%3B%20nxtR)%20is%26nbsp%3Blisted%20path%20on%20a%20cell%20(range).%3C%2FP%3E%3CP%3ESet%20fol%20%3D%20FSO.GetFolder(Sheet1.Range(%22f%22%20%26amp%3B%20nxtR))%2C%20this%20seems%20not%20to%20do%20a%20trick.%20Any%20suggestion%20please%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3404718%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3404862%22%20slang%3D%22en-US%22%3ERe%3A%20File%20system%20objects%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3404862%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1395706%22%20target%3D%22_blank%22%3E%40Rob233%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDoes%20this%20work%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESet%20fol%20%3D%20FSO.GetFolder(Worksheets(%22Sheet1%22).Range(%22F%22%20%26amp%3B%20nxtR).Value)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3408739%22%20slang%3D%22en-US%22%3ERe%3A%20File%20system%20objects%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3408739%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3Bdidn't%20work.%20However%2C%20I%20worked%20my%20code%20around%20for%20solution.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

If I am looping through a sub folder and I'd like to change folder path like:

Dim fol As Scripting.folder

'if Sheet1.Range("f" & nxtR) is listed path on a cell (range).

Set fol = FSO.GetFolder(Sheet1.Range("f" & nxtR)), this seems not to do a trick. Any suggestion please?

2 Replies

@Rob233 

Does this work?

 

Set fol = FSO.GetFolder(Worksheets("Sheet1").Range("F" & nxtR).Value)

@Hans Vogelaar didn't work. However, I worked my code around for solution.