Solved

Copying data from one spreadsheet to another

Posted on 2015-01-07
8
60 Views
Last Modified: 2015-02-05
Hi,

I currently have 5 different spreadsheets with different data on it, is it possible to copy all the data from each of the spreadsheets to a master spreadsheet automatically.

I tried various VBA examples online but can't find one that can copy multiple rows over to the master spreadsheet.

Thanks
0
Comment
Question by:MattToner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
8 Comments
 
LVL 12

Expert Comment

by:FarWest
ID: 40535832
if you want to copy certain  rows you can use Range
range("n1:n2")
where n1 is a start row number and n2
you can select and  copy the range and then select starting of destination and then paste

I hope this will help
0
 

Author Comment

by:MattToner
ID: 40535847
Hi, thanks for that, would you have a working example I could try?
0
 
LVL 12

Expert Comment

by:FarWest
ID: 40535887
this is a working example

Public Sub copyrows()
Sheet1.Activate
Sheet1.Range("1:4").Select
Selection.Copy
Sheet2.Activate
Sheet2.Range("1:1").Select
Sheet2.Paste
End Sub

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MattToner
ID: 40537416
Hi thanks.

Is it possible so that it automatically grabs it from the 5 spreadsheets and put it into a different workbook?
0
 
LVL 12

Accepted Solution

by:
FarWest earned 500 total points
ID: 40538406
check this code

Public Sub copyrows()
	Dim wsh As Worksheet, wsr
	Dim startrow As Integer
	Dim LastRow As Integer
	startrow = 1 ' first row to copy to in destination
	Set wsr = Worksheets("AllSheets") ' this is the sheet name that will merge all others

	For Each wsh In ActiveWorkbook.Sheets
		If wsh.Name <> "AllSheets" Then
			wsh.Activate
			LastRow = wsh.UsedRange.SpecialCells(xlCellTypeLastCell).Row
			wsh.Range("1:" + LTrim(Str(LastRow))).Select ' or comment this and uncomment next line  if you need specific rows in sheet
			'wsh.Range("1:4").Select
			Selection.Copy
			wsr.Activate
			wsr.Range("A" + LTrim(Str(startrow)) + ":A" + LTrim(Str(startrow))).Select
			wsr.Paste
			startrow = startrow + LastRow ' + 1 or + 2 if you need spaces between sheets
		End If
	Next
End Sub

Open in new window

0
 

Author Comment

by:MattToner
ID: 40539730
Thank you, I'll have a look at it
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40590665
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question