+ Reply to Thread
Results 1 to 3 of 3

Extract multiple cell values to master from multiple workbook in folder

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    Extract multiple cell values to master from multiple workbook in folder

    Dear experts

    good evening to all

    I have more than 20 files in folder, I want extract cell values of each workbook through macro button.

    MASTER SHEET COLLECT VALUES OF CELL(B7,B8,B13 & START FROM E24,E25,E26,E27 TILL VALUES END IN COLUMN)

    ALL FILES REFERENCE SHEET IS Sheet1.

    please find the attachment you might be understand what am i looking for ?



    thanks to all

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extract multiple cell values to master from multiple workbook in folder

    Basic method like so:
    Option Explicit
    
    Sub ImportOrders()
    Dim fPATH As String, fNAME As String, NR As Long
    Dim wbDATA As Workbook, Dest As Worksheet
    
    Application.ScreenUpdating = False                              'speed up macro execution
    Set Dest = ThisWorkbook.Sheets("Sheet1")                        'macro goes in master .xlsb
    NR = Dest.Range("A" & Dest.Rows.Count).End(xlUp).Row + 1        'next empty row to add data
    
    fPATH = "C:\Path\To\My\Orders\"                                 'path to import files, remember the final \
    fNAME = Dir(fPATH & "*.xls")                                    'get first filename from fPATH
    
    Do While Len(fNAME) > 0                                         'repeat loops until all files processed
        Set wbDATA = Workbooks.Open(fPATH & fNAME)                  'open found file
        With wbDATA.Sheets("Sheet1")                                'reference sheet1 on found file
            Dest.Range("A" & NR).Value = .Range("B7").Value         'transfer data
            Dest.Range("B" & NR).Value = .Range("B8").Value
            Dest.Range("C" & NR).Value = .Range("B13").Value
            .Range("E:E").SpecialCells(xlConstants, 1).Copy         'column E, spot only the numbers and copy them
            Dest.Range("D" & NR).PasteSpecial xlPasteValues, Transpose:=True
        End With
        wbDATA.Close False                                          'close the found file
        NR = NR + 1                                                 'increment to next empty row
        fNAME = Dir                                                 'get next filename
    Loop
    
    Application.ScreenUpdating = True
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    Re: Extract multiple cell values to master from multiple workbook in folder

    SUPERB CODE THANKS ALOT FOR SPARED YOUR TIME FOR ME!!!

    CAN YOU HELP ME ON MY THREAD
    http://www.excelforum.com/excel-prog...30#post3315930

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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