Create Directory Path From Cells

Jun 10, 2008

This should be so easy, but I know I am missing something. I know that you can only create one directory on one statement line at a time with MkDir. in the "var_dir_path" resides a part number that changes dynamically.

Private Sub CreateFolderFromCellPath2_Click()...

View 6 Replies


ADVERTISEMENT

Conditional Directory Path From Cells

Jun 12, 2008

Customer directory inside the "masterfile drive". Part number subdirectory of the Customer Directory. 5 subdirectorys of the Part Number Directory. 2 subsubdirectories of one of the 5 subdrectories. That is reference only.

Private Sub CreateFolderFromCellPath8_Click()
Dim s1 As String, s2 As String, s3 As String, s4 As String, s5 As String, s6 As String, s7 As String, s8 As String, s9 As String, s10 As String
var_path_masterfile_cust_name = Worksheets("RFQ").Range("AF48").Value
var_path_part_number = Worksheets("RFQ").Range("AF49").Value
var_path_Correspondence = Worksheets("RFQ").Range("AF50").Value
var_path_Customer_Service = Worksheets("RFQ").Range("AF51").Value
var_path_Engineering = Worksheets("RFQ").Range("AF52").Value
var_path_Purchasing = Worksheets("RFQ").Range("AF53").Value
var_path_Quality_Assurance = Worksheets("RFQ").Range("AF54").Value
var_path_Sales = Worksheets("RFQ").Range("AF55").Value....................

The variables are grabbing the path directly out of cells in Excel that are concantenated strings. This works great if the customer folder (s1) is not created. I would have thought that the way that I had the If/Then setup, that it would run smoothly, but if the customer folder is already created, the Debug highlights the very first MkDir s1

View 4 Replies View Related

Reference Cell's Value In Directory Path Name?

Apr 23, 2013

I have a worksheet (sheet1 in book1.xlsx) that references another worksheet (sheet2 in book2.xlsx) in a different file. The latter file, however, is stored in a directory that changes. Call it MYPATH for the time being. I'm trying to use a formula (not macros, which aren't allowed in this office) to reference the directory path using the dynamic name.

For example, in the first worksheet, cell A15 contains the word MYPATH. I'd like cell A1 to have a formula like this: ='C:&$A$15&subdir[book2.xlsx]sheet2'!B50

so that if I change the value of cell A15 in book.xlsx to ANEWPATH, the path reference will switch to the book2.xlsx in ANEWPATH, not MYPATH.

View 3 Replies View Related

Dialog Box For Selecting Directory/path

Jul 27, 2007

I've seen many posts advocating the use of BrowseFolder.zip located at
[url]

And some others saying to use the FileDialog object (if you use Excel 2002, or older(?))

I have to admit both are above my prior experience level, but I think I can do it if I understand what their function, requirements, and output are.

All I need is a dialog box that preferably lets me select the default directory, and then allows the user to select the target directory.

View 9 Replies View Related

Place Username In Directory Path

Mar 9, 2007

I've been trying to get the network username and found the solution on a previous thread. I have got to the point where I have copied the network username to my workbook. I now want to save this workbook into My Documents using that value for the username. So, so far i have:

'Get username from network

Dim User As String

CUser = Environ("username")
Cells(5000, 9) = Environ("username")
user = Application.ActiveCell

' Protect workbook and save in My Documents

ActiveSheet.Protect

ChDir "C:Documents and SettingsXXXXXXXMy Documents"

ActiveWorkbook.SaveAs Filename:= _
"C:Documents and SettingsXXXXXXMy DocumentsSalary Review Data 2007 - " & country & ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

ActiveWorkbook.Close

The user who saves this workbook, will be doing so on their own PC's so i need the file to save to their 'My Documents' folder. So i need to replace the red X's with the user's network username (which I have extracted and dim'd as User. How do i write this into the path of the directory?

View 2 Replies View Related

Load Dialog Box In Last Directory Path Opened?

Jul 11, 2014

I have a file which is opened every so often. This file when opened it presents a userform in which you browse two files which then get loaded into the document and some charts/pivots are updated with the information from the loaded files.

When you click on the browse button it opens the browser dialog box in the libraries path. I am wondering if it's possible to have the dialog box open in the last directory path used.

For example:

A week ago I opened the file from the path C:UsersIntiDocumentsProjectsTea Project

What I would like to happen is that when I open the file today and I click the "Browse" button (which opens the dialog box to find files in your computer) for the dialog box to open automatically in the path C:UsersIntiDocumentsProjectsTea Project

Then if tomorrow the file is opened from the path C:UsersIntiPicturesProjectsTea2Project

Then a week from now when you browse for the file the dialog box opens automatically in the C:UsersIntiPicturesProjectsTea2Project path

This is what I have right now and it always opens the dialog box on C:UsersIntiDocuments

[Code] .....

View 1 Replies View Related

Using Excel Cell As Pointer In Directory Path?

Oct 2, 2011

I have a few files all with the same name for a few different members of staff, so I save them in different paths to keep them separate.

eg

c:documentsdatajo blogsexcelfile.xls
c:documentsdatafred smithexcelfile.xls
c:documentsdatajane jonesexcelfile.xls

cells is the sheet contain the persons name

jo blogs
fred smith
jane jones

I want to be able to use this for others in the organisation and make it a simple as possible

Is there a way to use the cell contents in the path name (without opening the sheet first)

I know I can point to each cell in the other file and excel will use it but there must be a way of making this happen more automated by using the cell contents

View 5 Replies View Related

Loop Through Directory And Return Path File And A Value

Mar 15, 2014

I need a macro to loop through a dir and the sub directories to find xlsm files, when it finds one open, go to the sheet named data, look at c1 and if the value is between 12.1 and 13.4 then i need it to write the file path, filename to a1 in my excell sheet and then write the value from c1 in the original file to A2 of line in my excel sheet.

I have hobbled pieces of code together without any good results.

View 2 Replies View Related

Change To Directory Path Located In Cell

Oct 16, 2008

I am trying to use the same VBA code for different applications using variables.

Basically I want to have a variables sheet that has the different directories based on the macro selection. My variable sourceloc would change based on the variable name on the sheet.

sometimes I would want it to equal what was in a1 and sometime I would want what was in a2
a1 cell contains "f:filezilla files
a2 cell contains "f:dmc files
This is the code I started and it gives compile error when ChDir = sourceloc is reached

Public sourceloc

Sub filezillasettings()
Dim sourceloc As String
sourceloc = ActiveSheet.[a1] ' a1 cell contains the directory name and folder name =

End Sub

View 7 Replies View Related

Automatically Remove Folder From Directory Path

May 9, 2007

i am wanting to automaticaly remove a file from a directory when this directory is populated and move to another directory that is secure, how would i do this? just say directory 1(where it will be removed from) is s:/ddc/reports

moved too-- s:/ddc/test

test folder will be secure

View 5 Replies View Related

Displaying The Current Opened File's Directory Path?

Sep 25, 2008

What is the easiest way to display in a cell the opened file's directory path where the file is stored? I would like to use some sort of formula (instead of the VB route) but I don't know if such a thing exists.

View 5 Replies View Related

Open All Excel Files In Directory - Code Doesn't Work For One Specific Path

Feb 8, 2014

I have my code here:

VB:
Sub openfiles()Dim Path As String
Dim ExcelFile As String
' Path = GetFolder("C:UsersKinteshDesktop")
Path = "C:UsersKinteshDesktopVBA programmingMaps"
ExcelFile = Dir(Path & "*.xls")

[Code] ....

NextCode:
GetFolder = sitem
Set fldr = Nothing
End Function

My problem is that the code all actually works (including the function and when I use the commented part), but pointing to this one specific directory (the one I'm using right now), literally nothing happens.

View 6 Replies View Related

Create Directory Tree

Dec 9, 2009

I've been trying my best to create a directory structure using VBA and Excel, and have run out of patience on how best to do this. My goal is to create a directory tree containing 2 levels. The 1st level (Main Folders) will be named from data in Column A of an Excel Spreadsheet, the 2nd level (Subfolders) will be created from data in Columns B, C and D of the spreadsheet. I've been using the following code with success, but don't know how to create subdirectories:

Sub StartHere()
Dim rCell As Range, rRng As Range
Set rRng = Sheet1.Range("A1:A20")
For Each rCell In rRng.Cells
CreateFolders rCell.Value, "C: est"
Next rCell
End Sub

Sub CreateFolders(sSubFolder As String, ByVal sBaseFolder As String)
Dim sTemp As String
'Make sure the base folder is ready to have a sub folder
'tacked on to the end
If Right(sBaseFolder, 1) <> "" Then
sBaseFolder = sBaseFolder & ""
End If............

View 5 Replies View Related

Create List Of Files In A Directory

Oct 20, 2007

Is it possible to create a VBA script that will list the filenames of files in a set directory? I have about 100 directories, each containing 1000 files and they need to go into an excel spreadsheet (each file on a new row)so they can be audited... ;(

View 3 Replies View Related

How To Create Copy Of Excel Workbook In Same Directory

Mar 20, 2014

I have Workbook named"Test_Template" in below specified path this is not the active workbook.

It is saved in strFName = ThisWorkbook.Path & "Backup" & "Test_Template.xlsx"

I need to create a copy of the same workbook named as "Copy_Test_Template.xlsx" in the same folder(Backup), same specified path on button click.

[Code] .....

But this creates a "Copy_Test_Template.xlsx outside the Backup folder, i want it in the back up folder.

View 2 Replies View Related

Create Folder.... Make Directory MkDir

Nov 11, 2003

how can I creat a directory and then save the same file into that directory. At the moment Im using -

ThisFile = Range("T3").Value
ActiveWorkbook.SaveAs FileName:=ThisFile

...which works great, but before I do this, I want to create a folder with the name the name/value in T4, then ofcourse save the file into that folder ....

View 9 Replies View Related

Create Directory Or Folder Using Date In Cell

Aug 25, 2008

How can you add the date from a sheet say A1 which is a long date and make a directory which the date incorporated into the new directory name?

View 2 Replies View Related

Macro: Create Directory Based On Active Workbook And Save To It

Sep 8, 2006

Read “My Documents” Path And Use Result

Problem:

Note:

Typical user OS will be Windows XP Pro / Win 2K
Excel version : 97 / 2002 / 2003

1. Corporate network security settings will only allow directory/subdirectory creation in the “My Documents” section of customers individual computers.

2. Per customer request, VBA application needs to save extracted files for future use.

3. I can specify an initial “My Documents” subdirectory be made and the VBA application file be loaded/copied into that location – i.e. – “My DocumentsCat”.

4. When VBA application is opened from that specified directory, (first time), the application needs to make an additional subdirectory tree to save future files. I can read the opened from location via VBA with the following:

Dim filepath As String
filepath = ThisWorkbook.Path
As an example – this code would produce a string definition of “filepath” – such as the following:............................

View 5 Replies View Related

Search Path & Create Hyperlink To File

Oct 1, 2009

I'm trying to add code that create a hyperlink to a file in a recently created folder in the path of L:Elec Dept ProjectsRELEASED FOR CONSTRUCTION". The code below should find the newly created *BOM*.xls created and created a hyperlink in the next available row starting on row 27 and column O on my worksheet "BOM". The code currently runs with no errors, but I'm not seeing any resulting text with path / links created.

View 5 Replies View Related

CHECK For PATH EXSISTANCE - CREATE IF FLASE...

Jun 1, 2006

I know how to check for a path exsistance. If Dir(DEST, vbDirectory) = "" Then MsgBox "Path does not exist" (while DEST = "C:TempMike"). I would like to add a question which will determine if the user wants the Macro to create that Path.

1. I do not know how to create that path via VBA Code.
2. What if 'C:Temp' allready exists and only 'Mike' has to be added/created !?

View 2 Replies View Related

Create & Save Workbook To Same Path As Macro File

Aug 21, 2008

I have code to create a new workbook, and when I try to rename it I get "Compile error: Can't assign to read-only property."

Dim objXlApp As Object
Dim wkb As Workbook
Dim wks As Worksheet
Set objXlApp = CreateObject("Excel.Application")
' Create a workbook
Set wkb = objXlApp.Workbooks.Add
' Delete all worksheets bar the first one.
For Each wks In wkb.Worksheets
If Not wks.Index = 1 Then
wks.Delete

End If
Next wks
'Create some worksheets and names
With wkb
.Worksheets(1).Name = "myWorksheet1"
.Worksheets.Add.Name = "myWorksheet2"
.Worksheets.Add.Name = "myWorksheet3"
.Worksheets.Add.Name = "myWorksheet4"
End With...................................

View 5 Replies View Related

Create Directory From Cell & Save Workbook With Cell Value

Dec 3, 2006

what code can be used to be place in a Command Button on a worksheet that will use the value in a cell, change it to the directory where it have to be saved and save it to the value of another cell. Example:

On a worksheet called "Customer", at cel A1 will be the customer's name and at cell A2 will be the asset number. Now let's say a directory does not yet exist on the root for this customer, a new directory must be created in the root directory by using the name in A1, and the workbook must then be copied and saved under the value of A2.

View 6 Replies View Related

Save Hyperlink Path For File With Absolute Path And Non-Relative?

Mar 4, 2013

is it possible to configure Excel in order to save the Hyperlink path for a file with absolute path and non relative?

I notice that the hyperlink is ....pdf ry.pdf

if I change the position of the file excel there is a problem!

I would like to save es. d:invoichepdf ry.pdf

View 1 Replies View Related

Plan Path And Actual Path Distance Calculation?

Feb 11, 2014

I am using an XY scatter chart that displays the planned path and an actual path as I go. The planned path is set up in 100' increments and goes 12000' and actual path varies along the way.

My data that I use is the Northing (ft), Easting (ft) and Vertical Section (ft) for both the planned path and actual path.

I was wondering if there was an east way to get that information from the chart or if there is a formula that would allow me to calculate distance between the two points by using the data I use for my chart.

View 1 Replies View Related

Macro To Separate File Name And Path From Complete Path

Oct 3, 2012

I want to run a macro to separate File Name and Path from the given complete path

For Example

Code:

In Column A : Given Complete Path " C:MainFolderRecordsSubFilesFile1Record.pdf

I need it separeted like

Code:

In Column B :File Name = Record.pdf
In Column C :File Path = C:MainFolderRecordsSubFilesFile1

Is there any way to do this through a macro

View 2 Replies View Related

Search In Directory For Specific Cells

Feb 19, 2008

I got a directory with several xls-files.

I want in an new excel file to search automatically for all strings (11 till 48) in all files this particular directory.

All the strings (11-48) are being placed on this new file in worksheet 1.

View 9 Replies View Related

List All Files From Directory And Sub Directory?

Sep 5, 2013

The script collects all the files in directory and sub-directories and list them in ascending format, I want them to get in transpose format. like for example: Root folder has many sub directories and in them a sub directory XYZ has 5 excel files, it will get the sub directory name in Col A and transpose all .xls files.

Col A | Col B________|Col C_________ |Col D___________|Col E________|
XYZ__|C:/root/test.xls|C:/root/Sales.xls |C:/root/Report.xls |C:/root/sam.xls|

[URL]

View 8 Replies View Related

Open File From Directory & Name Stored In 2 Cells

Aug 29, 2007

I have numerous sub directories, C:/Jobs/12500 – 12599, C:/Jobs/12600 – 12699 etc, within these directories exist spreadsheets with file names like 12675.xls (in this case it’s in the “12600 – 12699” directory). In my open spreadsheet, in cell A1, there is a job number, say 12675. I want to find and open the existing 12675.xls spreadsheet. If the spreadsheet does not exist, a template (Costing.xlt), in a fixed directory, is opened and then saved, in the correct sub directory i.e. C:/Jobs/12600 – 12699/12675.xls. I am now using the following code, but the directory is fixed. How can it be modified to work with variable directories?

On Error Resume Next
Workbooks.Open Filename:="C:Spreadsheets" & Range("A1") & ".xls"
If Err <> 0 Then
Workbooks.Open Filename:="C:SpreadsheetsCosting.xlt"
ActiveWorkbook.SaveAs "C:Spreadsheets" & Range("A1") & ".xls"
End If
On Error Goto 0

View 3 Replies View Related

Shortest Path Between Cells (VBA)

Mar 2, 2014

I am working on a project to clear festival events with simulation. Therefore I need a grid of Excel cells (the field), let's say 11x11 (B2:L12). And the exit is in cell A7.

I am looking for an algorithm which fills this field with distances to the exit. For horizontal and vertical movements the distance is 1, and for diagonal movements the distance is 1.5

Say I made a class Coordinate which has two points, X & Y I declare a variable point, as the location I am in (the active cell) and a constant exit (the coordinate of the exit)

And then I would like a function in VBA which does:

[Code] ......

How to approach this?

View 6 Replies View Related

File Path From Cells In Workbook

Jul 23, 2014

here I have a few good and perfect codes, the issue is my systems changed so I need it to look in some different places for data.

basically I need to create a file path that includes the data from a cell. this cell is found be searching a table full of data.

see the code below

Code:

Sub saveandprint()
Dim MyPath As String
MyPath = MyPathstart & "Invoice" & "" & Format(Date, "dd-mm-yy")
MyPath1 = "Z:Invoices Temp GKL " & Range("B16").Value & Format(Now, "hhmm")

[Code]....

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved