Hi,
I have columns of data in a master workbook. I want to be able to copy a single column to a separate closed workbook using a macro button. E.g. If the closed workbook is empty to start with. Then clicking the button once will copy the data to Column 1 in the closed worksheet selected, then clicking it again will copy the data to Column 2... and the next time to Column 3 etc, so that each iteration of data is saved in columns.
I haven't had much like finding a code for this and I am rather new to VBA, I came across this code which currently copies cells from one workbook to a closed one, and I can modfy this to include the column range I'm interested in, but I don't know how to make it so that each time the code is run, it copies to the next subsequent column, instead of overwriting the same column again and again.
Option Explicit
Sub copyDataToClosedWorkbook()
Dim wbTo As Workbook
Dim wbFrom As Workbook
Set wbFrom = ThisWorkbook
' prevent the user from seeing the workbook being opened
Application.ScreenUpdating = False
'change foldername
Set wbTo = Workbooks.Open("C:\FolderName\Test.xls", _
False, True)
wbTo.csheet1.Cells(10, 4).Value = wbFrom.Sheet1.Cells(1, 3).Value
wbTo.Close True 'save & close
Application.ScreenUpdating = True
Set wbTo = Nothing
Set wbFrom = Nothing
End Sub
Thanks a lot for your help!
Bookmarks