+ Reply to Thread
Results 1 to 4 of 4

Linking question

Hybrid View

Doc1701 Linking question 03-19-2008, 05:40 PM
Leith Ross Hello Doc1701, Welcome to... 03-19-2008, 06:40 PM
Doc1701 Excellent! 03-20-2008, 04:36 PM
Leith Ross Hello Doc, This macro will... 03-20-2008, 05:13 PM
  1. #1
    Registered User
    Join Date
    03-19-2008
    Posts
    2

    Talking Linking question

    I haven't done much page/cell linking with Excel but I'm hoping that there is a relatively easy way to have one Excel file automatically update and compile information from multiple randomly named other files. Perhaps the only criterion is that they be dumped into the same folder? Can anyone tell me if this is possible to set up? I've got a ton of information coming in from many people using the same form excel file and i'd like to easily compile all info from these docs into one.

    Thanks!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Doc1701,

    Welcome to the Forum!

    If the workbooks all have the same format and are saved in a single folder, it is quite easy to summarize the information in a master workbook. I have several macros written to do this. Let me know more about how the information is laid out and I can post or modify one the macros for you.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    03-19-2008
    Posts
    2

    Excellent!

    Thanks so much! The form is basic order sheet and has input cells for catalog numbers, an item description, price, vendor, and account. The names of the files are highly random (as each user customizes this). But if this info from these fields could be categorized according to account, with each account sheet listing columns for vendor, item, price and description, then having any/all info transferred over. That would be fantastic!

    At the moment I'm not sure exactly which cells these are in...I can check/adapt.

    Doc

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Doc,

    This macro will copy all the .xls files from a folder. A worksheet with a common name in the workbooks is appended to the summary sheet in the main workbook. The only changes you need make are to the folder name (actually the path) and the name of the common sheet in the other workbooks. The are marked in the code in blue.
    'Written: March 10, 2008
    'Author:  Leith Ross
    'Summary: Opens Workbooks of the user's choosing, copies all the information from
    '         a sheet with a common name, and copies it to a summary sheet in the
    '         workbook that is running the macro.
    
    
    Sub SummarizeWorkbooks()
    
      Dim DataSheet As String
      Dim FileName As String
      Dim FolderName As String
      Dim MyFiles As Variant
      Dim MyWkb As Workbook
      Dim N As Long
      Dim NextRow As Long
      Dim Wkb As Workbook
      
        DataSheet = "Sheet1"
        Set MyWkb = ThisWorkbook
        FolderName = "C:\Documents and Settings\Owner\My Documents"
       
       'Find all "xls" file types in the folder
        FileName = Dir(MyPath & "\*.xls", vbNormal)
          Do While MyName <> ""
             ReDim Preserve MyFiles(N)
                MyFiles(N) = FileName
                N = N + 1
            FileName = Dir
          Loop
        
        Set SummarySheet = MyWkb.Worksheets("Summary")
          With SummarySheet.UsedRange
            NextRow = .Rows.Count + .Row
            GoSub FreeRows
          End With
            
          Application.ScreenUpdating = False
          
            For Each F In MyFiles
              Set Wkb = Workbooks.Open(FileName:=F, ReadOnly:=True)
                With Wkb.Worksheets(DataSheet)
                  .UsedRange.Copy Destination:= _
                    SummarySheet.Cells(NextRow, "A")
                  NextRow = NextRow + .UsedRange.Rows.Count
                  GoSub FreeRows
                End With
              Wkb.Close
            Next F
            
          Application.ScreenUpdating = True
        Exit Sub
        
    FreeRows:
        If NextRow > SummarySheet.Rows.Count Then
           MsgBox "Can Not Copy " & DataSheet & " to " & SummarySheet.Name _
                & ", Not Enough Rows left.", vbCritical
           Exit Sub
        End If
        
        Return
        
    End Sub
    Sincerely,
    Leith Ross
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

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