Results 1 to 3 of 3

Referencing filename to a Cell

Threaded View

Laylow Referencing filename to a Cell 04-01-2011, 10:08 AM
TMS Re: Referencing filename to a... 04-01-2011, 10:15 AM
Laylow Re: Referencing filename to a... 04-01-2011, 10:27 AM
  1. #1
    Registered User
    Join Date
    11-17-2010
    Location
    london, England
    MS-Off Ver
    Excel 2003
    Posts
    19

    Referencing filename to a Cell

    Dear All,

    The code I have below, extracts data from a closed file within a specific folder.

    For every file I want to extract data, I have to edit the code within the module.

    What I will like to do is to reference this part of my code to a cell say "A1".

    This is where my code has
     Files (1) = "temp2"
    The below is my code:

    
    Sub ConsolFiles()
    
    Dim wsMaster As Worksheet
    Set wsMaster = Worksheets("Mastersheet")
    Dim nextrow As Long
    
    Dim Files(1 To 1) As String
    
    ' This part needs to reference to a fixed cell within the Master sheet.
       Files(1) = "temp2"
      
    Dim filepath As String
    
    ‘Filepath goes into below
       filepath = "C:\Documents …………."
    Dim filenum As Integer
    
    Application.ScreenUpdating = False
    
    With wsMaster
       .Cells.Clear
    End With
       
    For filenum = 1 To 1
    nextrow = wsMaster.UsedRange.Rows.Count + wsMaster.UsedRange.Row
    
    Workbooks.Open (filepath & Files(filenum))
    Worksheets("Accident Book").Range("A6:N" & Range("A" & Rows.Count).End(xlUp).Row).Copy _
    wsMaster.Cells(nextrow, 1)
       
    Next
    
    ThisWorkbook.Activate
    Call CloseAll
    
    Application.ScreenUpdating = True
    
    End Sub

    Kind Regards

    Laylow
    Last edited by Laylow; 04-01-2011 at 10:28 AM.

Thread Information

Users Browsing this Thread

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

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