+ Reply to Thread
Results 1 to 2 of 2

Updating Multiple Rows Of Data

Hybrid View

nagajan Updating Multiple Rows Of Data 12-13-2012, 03:29 PM
xladept Re: Updating Multiple Rows Of... 12-13-2012, 04:17 PM
  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    1

    Cool Updating Multiple Rows Of Data

    Hello all,

    I have 16 files for my colleagues recording daily on open and closed cases, i need to check daily what has been closed and copy the row over in my master file but doing on by one is too time consuming.

    can a macro be rung so once i have all 17 files open it can look through all the open cases in the master and check if closed in any of the other 16 then copy over.

    The unique ref will be a customer number so that can be used for the look up.

    any ideas???

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Updating Multiple Rows Of Data

    Hi nagajan,

    You want to "run the directory", interestingly - yours is the third I've encountered this week - so here's a working version that you should be able to adapt with your own book and sheet names:

    Sub PasteBase(): Dim wb As Workbook, ws As Worksheet, wd As Worksheet, r As Long
    Dim S As String, P As String, U As String: P = ActiveWorkbook.Path & "\": U = Dir(P)
                        
    'When running a directory you need to specify the first in the folder
    'You get that by setting the path & backslash i.e "C:\Documents and Settings\"
    
    'Unless you know the Path for these files you'll need to have one of them up at invocation
    
    For Each wb In Workbooks                 'If "Master" is open then Set receiving sheet
    If wb.Name Like "Master.xls*" Then GoTo SetDB
    Next: Workbooks.Open Filename:=P & "Database"  'Else open "Database"
    SetDB: Set wd = Workbooks("Database").Sheets("Direct Personel"): r = 3
    SetaBook:
    If U Like "Database.xl*" Then GoTo GetaBook
    If InStr(1, U, ".xl") = 0 Then GoTo GetaBook
    If InStr(1, U, "Report") Then                 'this only if there are others in the folder
    Workbooks.Open Filename:=P & U, UpdateLinks:=0
    Set wb = ActiveWorkbook: Set ws = wb.Sheets("Direct Personel")
    ws.Range("A3:D59").Copy wd.Cells(r, 1): wb.Close SaveChanges:=False
    r = r + 59: End If
    GetaBook: U = Dir()        'Get another book
    If U = "" Then Exit Sub
    GoTo SetaBook: End Sub
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ 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