• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Export single column into multple Workbooks

marreco

Member
hi.

How copy a columns data Wb1 and paste into all Wbs inside folder?
Code:
Sub Copy_Columns_Paste_Into_Multiple_Workbooks()
    Dim sourceSheet As Worksheet
    Dim folder As String, fileName As String
    Dim destinationWorkbook As Workbook

    Set sourceSheet = ActiveWorkbook.Worksheets("defaultSheet")

    folder = "C:\Users\marreco\"
    fileName = Dir(folder & "*.xlsx", vbNormal)
    While Len(fileName) <> 0
        Set destinationWorkbook = Workbooks.Open(folder & fileName)
'.....................................all workbooks has a defaultSheet inside it
        sourceSheet.Range("J6:J106").Copy Destination:=destinationWorkbook.Sheets(1)
        destinationWorkbook.Close True
        fileName = Dir()
    Wend

End Sub
 
Without checking be running your code, I think this line needs a bit more:
Code:
sourceSheet.Range("J6:J106").Copy Destination:=destinationWorkbook.Sheets(1)

Where do you want to paste this data in the worksheet (you only need specify the topmost cell)? if you wanted to paste to cell Z1 and below then:

Code:
sourceSheet.Range("J6:J106").Copy Destination:=destinationWorkbook.Sheets(1).range("Z1")
 
Back
Top