Results 1 to 22 of 22

Copy specific columns from multiple files in folder and combine those columns in workbook

Threaded View

  1. #1
    Registered User
    Join Date
    11-14-2022
    Location
    chennai
    MS-Off Ver
    2016
    Posts
    30

    Copy specific columns from multiple files in folder and combine those columns in workbook

    Dear Gurus,
    I got the below code that it combine sheets from all the files in the folder copy to another workbook, the codes work well. But i want to copy specific columns from all the files, I tried i cannot able to get. Can you help me here please.
    I think there is no need for attachment.
    Sub MergefilesinaSheet()
    
    Dim myactiveworkbook As Workbook
    Dim mergeObj As Object, dirObj As Object, filesObj As Object, everyObj As Object
    Application.ScreenUpdating = False
    
    
    Set mergeObj = CreateObject("Scripting.FileSystemObject")
     
    'change folder path of excel files here
    Set dirObj = mergeObj.Getfolder("C:\Desktop\Merge files\")
    Set filesObj = dirObj.Files
    For Each everyObj In filesObj
    Set myactiveworkbook = Workbooks.Open(everyObj)
    
    
    Range("A1:AA" & Range("A3000").End(xlUp).Row).Copy
    ThisWorkbook.Worksheets("All Columns").Activate
     
    'Do not change the following column. It's not the same column as above
    Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
    myactiveworkbook.Close
    CopyColumnsByName
    
    Next
    Cells.WrapText = False
    Cells(1, 1).EntireRow.Delete
    
    End Sub
    Last edited by JaffarAhamed; 09-10-2023 at 12:04 PM. Reason: grammer mistakes

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Combine multiple sheets on basis of columns & copy to another workbook at specified sheet
    By sanjuss2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-21-2021, 10:13 AM
  2. [SOLVED] Copy specific columns from all excel files saved in selected folder
    By KKR1975 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-03-2020, 11:03 PM
  3. loop through files find columns and copy/paste them as columns in master workbook
    By Michal1111 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2018, 10:40 PM
  4. [SOLVED] Copy specific columns from multiple workbooks to new workbook
    By nwix in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2017, 10:48 AM
  5. [SOLVED] VBA to Copy the same Columns from multiple files in one folder
    By mcanant in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-16-2014, 03:15 AM
  6. Macro to combine multiple columns keeping few columns specific
    By lramesh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2013, 12:44 PM
  7. Opening all .csv files in a folder and deleting specific columns
    By jamesmac91 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-30-2012, 11:20 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