Results 1 to 5 of 5

Copy specific columns from all the files in the folder and combine those columns in sheet

Threaded View

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

    Copy specific columns from all the files in the folder and combine those columns in sheet

    Dear Gurus,
    I got the below code that it combine sheets from all the files in the folder copy to another workbook, the code works well. But i want to copy specific columns from all the files, I tried but i cannot able to get. Can you help me here please.
    I think there is no need for attachment. Can you asssume that there are 25+ files in a folder other folder path and result should come in the sheet1 in active workbook. If you still want sample files then i can share. thanks.
    Dear Gurus,
    I got the below code that it combine sheets from all the files in the folder copy to another workbook, the code works well. But i want to copy specific columns from all the files, I tried but 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 01:31 PM. Reason: added lines

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Copy specific columns from multiple files in folder and combine those columns in workbook
    By JaffarAhamed in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 09-13-2023, 04:11 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. [SOLVED] vba to copy specific sheet tab from several files folder to consolidation workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-15-2018, 06:16 AM
  4. [SOLVED] Copy specific columns in sheet A and paste in specific columns in sheet B
    By Vassen in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-09-2017, 05:27 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. Replies: 8
    Last Post: 04-04-2013, 08:02 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