Macro code relates to a specific folder, how do I modify so that the vb looks at a location found in a1 of sheet 1?

smerrick

Active Member
Joined
Feb 10, 2009
Messages
255
[h=2]
icon1.png
[/h]******** type=text/javascript><!--google_ad_client = "ca-pub-2974935598394359";/* Ad001 */google_ad_slot = "2220822013";google_ad_width = 234;google_ad_height = 60;//-->*********>******** type=text/javascript src="http://pagead2.googlesyndication.com/pagead/show_ads.js">*********><INS style="BORDER-BOTTOM: medium none; POSITION: relative; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 234px; PADDING-RIGHT: 0px; DISPLAY: inline-table; HEIGHT: 60px; VISIBILITY: visible; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px"><INS style="BORDER-BOTTOM: medium none; POSITION: relative; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 234px; PADDING-RIGHT: 0px; DISPLAY: block; HEIGHT: 60px; VISIBILITY: visible; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px" id=aswift_0_anchor></INS></INS>
Hello,</SPAN>

I have the following code that loops all the files in a folder and extracts data. However, sometimes the folder name changes. Is there a way that I can enter the path name in say a1 of sheet 1 and so when I run the macro the <ACRONYM title="visual basic for applications">VBA</ACRONYM> will refer to this location?</SPAN>


Extract of code:
F = Dir("C:\Users\wycmest1\Desktop\Test1\SUBMISSIONS\" & "*.xls")</SPAN>​
 

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
Try
Code:
Dim DirString as String
DirString = Range("A1").Text
F=Dir(DirString & "*.xls")
Think that should work
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,544
Members
449,316
Latest member
sravya

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