Results 1 to 6 of 6

Generate File path that has been created from another macro to Cell

Threaded View

dave1983 Generate File path that has... 08-22-2014, 05:38 AM
TonyS Re: Generate File path that... 08-22-2014, 06:50 AM
dave1983 Re: Generate File path that... 08-22-2014, 08:03 AM
dave1983 Re: Generate File path that... 08-26-2014, 04:37 AM
JOHN H. DAVIS Re: Generate File path that... 08-26-2014, 08:06 AM
dave1983 Re: Generate File path that... 08-28-2014, 05:49 AM
  1. #1
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Question Generate File path that has been created from another macro to Cell

    Good Morning

    I have the following Macro that someone helped me with, It was moving some files over to the end location but now it doesnt seem to be doing that, What I wanted to do is write the final folder path to Cell F2 once it has run through the macro.

    Sub Create_Folder_Move_Files()
    
         Dim strDefpath, mainfolder, subfolder, subsubfolder, strPathname As String
    
        Application.ScreenUpdating = False
        Application.DisplayAlerts = False
            
        On Error Resume Next                        ' If directory exist goto next line
    
        strDefpath = "\\ccfilesvr\shared\membership services\operations\supervisors\RESOURCE AREA stats & info\Statistics\Daily Stats Import\"  'Default path name
          
        mainfolder = Sheets("Move & Rename").Range("C2").Value              ' stores value of C2 cell
        subfolder = Sheets("Move & Rename").Range("D2").Value               ' stores value of D2 cell
        subsubfolder = Sheets("Move & Rename").Range("E2").Value            ' stores value of E2 cell
    
        If IsEmpty(mainfolder) Then Exit Sub
    
        MkDir strDefpath & mainfolder                 ' Check or create mainfolder
        strPathname = strDefpath & "\" & mainfolder
        
        If IsEmpty(subfolder) Then Exit Sub
      
        MkDir strPathname & "\" & subfolder           ' Check or create subfolder
        strPathname = strDefpath & "\" & mainfolder & "\" & subfolder
        
        If IsEmpty(subsubfolder) Then Exit Sub
        
        MkDir strPathname & "\" & subsubfolder         ' Check or create subsubfolder
        strPathname = strDefpath & "\" & mainfolder & "\" & subfolder & "\" & subsubfolder
        
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
         
    End Sub
    I then have this Macro set up to move the files

    Sub Move_CDN_CC()
        
        Dim strFile As String, strNewFile As String
        
        Const strSourcePath As String = "A:\"
        Const strDestinationPath As String = "P:\membership services\operations\supervisors\RESOURCE AREA stats & info\Statistics\Daily Stats Import\2014\"
        
        strNewFile = Sheets("Move & Rename").Range("A2").Value & " " & _
                     Format(Sheets("Move & Rename").Range("B2").Value, "dd mmm yy") & ".xls"
        
        If Dir$(strDestinationPath & strNewFile) <> "" Then
            MsgBox "There is already an existing file named " & vbLf & strDestinationPath & strNewFile, _
                   vbExclamation, "Dated File Name Exists"
            Exit Sub
        End If
        
        strFile = Dir$(strSourcePath & "CDN CC*")
        If strFile <> "" Then
            Name (strSourcePath & strFile) As (strDestinationPath & strNewFile)
            
        Else
            MsgBox "No file found. ", , "File Not Found"
        End If
        
    End Sub
    I will change this line

     Const strDestinationPath As String = "P:\membership services\operations\supervisors\RESOURCE AREA stats & info\Statistics\Daily Stats Import\2014\"
    To point to the cell with the final path string in it

     Const strDestinationPath As String = "Sheets("Move & Rename").Range("F2").Value"
    I assume that will work?
    Last edited by dave1983; 08-22-2014 at 05:59 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Generate path of a file in column and send email as attachment based on a cell value
    By anchuri_chaitanya in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-04-2013, 02:01 AM
  2. Create macro to generate hyperlink to a specific file from cell
    By Tranen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2012, 12:23 AM
  3. Macro to display File path on Cell Mouse over
    By Mysore in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2012, 01:25 AM
  4. macro to include cell contents b1 in file path
    By martindwilson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2008, 07:42 AM
  5. Automatically generate Code for a worksheet created by a macro
    By jthompson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2008, 06:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1