Results 1 to 5 of 5

Help to copy from multiple file and transpose data

Threaded View

  1. #1
    Forum Contributor
    Join Date
    10-29-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    142

    Help to copy from multiple file and transpose data

    Hi all
    I have code belove to copy from multiple file to wb MAIN.xlsx sheet(ketqua), soucre range as text and result as number

    Now I want this code copy then paste transpose value into sheet(ketqua), the result I want demo in sheet(ketquamongmuon)
    I attack some source files to more clear
    Public Sub DATA_2774()
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Dim cn As Object, rs As Object, i As Byte, lr As Long, lr2 As Long, z As Long, fso As Object
    Set cn = CreateObject("adodb.connection")
    Set fso = CreateObject("Scripting.FileSystemObject")
    Sheets("ketqua").Range("A1").CurrentRegion.Offset(1).ClearContents
        With Application.FileDialog(msoFileDialogOpen)
            .Filters.Clear
            .Filters.Add "2774", "*.xl*"
            .InitialFileName = "nguon*"
            .AllowMultiSelect = True
            .Show
            For i = 1 To .SelectedItems.Count
                cn.Open ("provider=Microsoft.ACE.OLEDB.12.0;data source=" & .SelectedItems(i) & ";mode=Read;extended properties=""Excel 12.0;hdr=no"";")
           
            Set rs = cn.Execute("select '" & fso.GetBaseName(.SelectedItems(i)) & "',val(f1) from [2774$D18:D28] ")
           
                lr = Sheets("ketqua").Range("A" & Rows.Count).End(3).Row
                If Not rs.EOF Then Sheets("ketqua").Range("A" & lr + 1).CopyFromRecordset rs
                rs.Close
                cn.Close
            Next
    End With
    
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] copy multiple selections in a row and transpose
    By Frankie_The_Flyer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-26-2022, 02:05 AM
  2. [SOLVED] Copy and Transpose multiple times in a new worksheet
    By dosydos in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-23-2018, 02:59 PM
  3. Help! Copy, transpose, consolidate data from multiple worksheets
    By indik in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-18-2016, 06:48 AM
  4. [SOLVED] copy column data from multiple tabs onto specified tab, transpose, repeat
    By bruno08102013 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-26-2014, 12:43 PM
  5. [SOLVED] How to Extract Data from Multiple Files in Same Folder and Copy Data to One File
    By champ052005 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2013, 01:25 PM
  6. [SOLVED] Copy and Transpose Data From Single Row to Multiple Rows
    By delinia in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-08-2013, 06:26 PM
  7. Replies: 4
    Last Post: 03-08-2013, 09:49 AM

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