ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy and Paste specific data (https://www.excelbanter.com/excel-programming/366779-copy-paste-specific-data.html)

lizb22

Copy and Paste specific data
 

Hi,

I have 1 spreadsheet with ALL data
I have 2nd spreadsheet that has a selection of data from 1st sheet

I need help with a loop that will go to 1st spreadhsheet, copy the data
only pertainting to the second one, and paste it into 2nd spreadsheet;

This is where I started:

Sub PasteFromMaster()
Dim start As Range
Dim finish As Range

Workbooks("Test_Master").Activate

Set start = Workbooks("Test_Master").Sheets("sheet1").Range("a 1:d1")
Set finish = Workbooks("Test_1").Sheets("sheet1").Range("a7")

start.Copy finish

Do While ActiveCell.Value < ActiveCell.Offset(1, 0)
ActiveCell.Offset(1, 0).Select

'Range "start:finish".Select ** not sure about this
Selection.Copy
Windows("TEST_1.xls").Activate
Range("A7").Select
ActiveSheet.Paste

Loop

End Sub

thanks
Liz


--
lizb22
------------------------------------------------------------------------
lizb22's Profile: http://www.excelforum.com/member.php...o&userid=36210
View this thread: http://www.excelforum.com/showthread...hreadid=560046


Don Guillett

Copy and Paste specific data
 
for a better way, have a look in vba help for FIND and FINDNEXT. there is an
example.

I don't understand this statement
copy the data only pertaining to the second one



--
Don Guillett
SalesAid Software

"lizb22" wrote in
message ...

Hi,

I have 1 spreadsheet with ALL data
I have 2nd spreadsheet that has a selection of data from 1st sheet

I need help with a loop that will go to 1st spreadhsheet, copy the data
only pertainting to the second one, and paste it into 2nd spreadsheet;

This is where I started:

Sub PasteFromMaster()
Dim start As Range
Dim finish As Range

Workbooks("Test_Master").Activate

Set start = Workbooks("Test_Master").Sheets("sheet1").Range("a 1:d1")
Set finish = Workbooks("Test_1").Sheets("sheet1").Range("a7")

start.Copy finish

Do While ActiveCell.Value < ActiveCell.Offset(1, 0)
ActiveCell.Offset(1, 0).Select

'Range "start:finish".Select ** not sure about this
Selection.Copy
Windows("TEST_1.xls").Activate
Range("A7").Select
ActiveSheet.Paste

Loop

End Sub

thanks
Liz


--
lizb22
------------------------------------------------------------------------
lizb22's Profile:
http://www.excelforum.com/member.php...o&userid=36210
View this thread: http://www.excelforum.com/showthread...hreadid=560046





All times are GMT +1. The time now is 08:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com