Creating Shortcut Sub-folders

runningmusicman

New Member
Joined
Mar 22, 2018
Messages
1
I need help as I have zero experience in VBA.

I have two columns of data, I am creating a folder titled Column A and a subfolder titled Column B. Now I want to take the name of the subfolder and search for it's corresponding project folder and replace the subfolder with a shortcuts folder to the actual project folder.

Here is what I have so far, minus a few lines it will create the folders and subfolders, but I failed at trying to do the shortcuts:

Sub Tester()


Const ROOT_FOLDER = "N:\Users\wdavis\QGIS\Sherburne County\Project Locations"
Const BASE_FOLDER = "N:\Projects Current"
Dim rng As Range, rw As Range, c As Range
Dim sPath, tmp, ProjPath As String
Dim i As Integer
Set rng = Selection
i = 1
For Each rw In rng.Rows
sPath = ROOT_FOLDER
bPath = BASE_FOLDER & "" & Cells(i, "B")
For Each c In rw.Cells
tmp = Trim(c.Value)
If Len(tmp) = 0 Then
Exit For
Else
sPath = sPath & tmp & ""
If Len(Dir(sPath, vbDirectory)) = 0 Then
ProjPath = Dir(bPath & " *", vbDirectory)
If (Len(ProjPath) > 1) Then
Cells(i, "B").Hyperlinks.Add Cells(i, "B"), ProjPath, TextToDisplay:=Cells(i, "B")
End If
End If
End If

Next c
i = i + 1
Next rw
End Sub



102103104105106107108109110111112114115116117118119120121122123124125126127128129130131132133vé7`ãW‚²PS€î²
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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