VBA Link to a folder using a cell

p0is0n0us

New Member
Joined
Apr 2, 2014
Messages
19
Hi all,

I have a question that I have not been able to work out. I have a 9 digit number in cell B2 and need to set the folder in VBA based on the number. Part of the map involves the first number of the 9 digit number so as an example:

Cell B2: 231231231

Folder map would be: I:\images\2\231231231

Any help would be greatly appreciated.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Maybe, something like:
Code:
    Dim FolderPath As String: FolderPath = "i:\images\2\" & ActiveSheet.Range("b2").Value & "\"
    If Dir(FolderPath) = "" Then MkDir FolderPath
    ChDir FolderPath
Hi all,

I have a question that I have not been able to work out. I have a 9 digit number in cell B2 and need to set the folder in VBA based on the number. Part of the map involves the first number of the 9 digit number so as an example:

Cell B2: 231231231

Folder map would be: I:\images\2\231231231

Any help would be greatly appreciated.
 
Upvote 0
I was thinking perhaps the path to be .......

Code:
FolderPath = " I:\images\" & Left(Activesheet.Range("B2").Value, 1) & "\" & Activesheet.Range("B2").Value
???
 
Upvote 0
I was thinking perhaps the path to be .......

Code:
FolderPath = " I:\images\" & Left(Activesheet.Range("B2").Value, 1) & "\" & Activesheet.Range("B2").Value
???

Thank you both for your assistance with this, saved me a lot of time :)

The above code worked like a charm.
 
Upvote 0

Forum statistics

Threads
1,215,013
Messages
6,122,690
Members
449,092
Latest member
snoom82

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