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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,216,746
Messages
6,132,479
Members
449,729
Latest member
davelevnt

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