Copy data from monthly workbooks paste in a single workbook
Closed
peerreh
Posts
2
Registration date
Wednesday August 10, 2016
Status
Member
Last seen
August 10, 2016
-
Aug 10, 2016 at 05:30 AM
peerreh Posts 2 Registration date Wednesday August 10, 2016 Status Member Last seen August 10, 2016 - Aug 10, 2016 at 05:41 AM
peerreh Posts 2 Registration date Wednesday August 10, 2016 Status Member Last seen August 10, 2016 - Aug 10, 2016 at 05:41 AM
Related:
- Copy data from monthly workbooks paste in a single workbook
- Tmobile data check - Guide
- Transfer data from one excel worksheet to another automatically - Guide
- Gta 5 data download for pc - Download - Action and adventure
- Digital data transmission - Guide
- Display two columns in data validation list but return only one - Guide
1 response
peerreh
Posts
2
Registration date
Wednesday August 10, 2016
Status
Member
Last seen
August 10, 2016
Aug 10, 2016 at 05:41 AM
Aug 10, 2016 at 05:41 AM
Hi Guys,
I have the below Macro that I am currently using. However, it copy and paste data from only 1 workbook. I need to repeat this 12 times to copy data from the 12 workbooks and paste data in 12 different sheets. I am stuck with this. Please help.
Sub Macro1()
' Get customer workbook...
Dim customerBook As Workbook
Dim filter As String
Dim caption As String
Dim customerFilename As String
Dim customerWorkbook As Workbook
Dim targetWorkbook As Workbook
' make weak assumption that active workbook is the target
Set targetWorkbook = Application.ActiveWorkbook
' get the customer workbook
filter = "Text files (*.xlsx),*.xlsx"
caption = "Please Select an input file "
customerFilename = Application.GetOpenFilename(filter, , caption)
Set customerWorkbook = Application.Workbooks.Open(customerFilename)
' assume range is A1 - C10 in sheet1
' copy data from customer to target workbook
Dim targetSheet As Worksheet
Set targetSheet = targetWorkbook.Worksheets("USER")
Dim sourceSheet As Worksheet
Set sourceSheet = customerWorkbook.Worksheets(1)
targetSheet.Range("A1", "C10").Value = sourceSheet.Range("A1", "C10").Value
' Close customer workbook
customerWorkbook.Close
End Sub
I have the below Macro that I am currently using. However, it copy and paste data from only 1 workbook. I need to repeat this 12 times to copy data from the 12 workbooks and paste data in 12 different sheets. I am stuck with this. Please help.
Sub Macro1()
' Get customer workbook...
Dim customerBook As Workbook
Dim filter As String
Dim caption As String
Dim customerFilename As String
Dim customerWorkbook As Workbook
Dim targetWorkbook As Workbook
' make weak assumption that active workbook is the target
Set targetWorkbook = Application.ActiveWorkbook
' get the customer workbook
filter = "Text files (*.xlsx),*.xlsx"
caption = "Please Select an input file "
customerFilename = Application.GetOpenFilename(filter, , caption)
Set customerWorkbook = Application.Workbooks.Open(customerFilename)
' assume range is A1 - C10 in sheet1
' copy data from customer to target workbook
Dim targetSheet As Worksheet
Set targetSheet = targetWorkbook.Worksheets("USER")
Dim sourceSheet As Worksheet
Set sourceSheet = customerWorkbook.Worksheets(1)
targetSheet.Range("A1", "C10").Value = sourceSheet.Range("A1", "C10").Value
' Close customer workbook
customerWorkbook.Close
End Sub