Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Macro to paste selected data to new book

I need a macro that will enabel me to perform the following function:

1. Paste selected data (particular range of cells) from worksheet A
(residing in workbook A) to a new Book 1 worksheet.
2. Paste selected data (particular range of cells) from worksheet B
(residing in workbook A) to the same Book 1 worksheet. This data will be
pasted on the next available empty row below the data in step 1.
3. Continue to paste data from worksheet 3 (and on) to next available row in
Book 1.

Thanks in advance for your help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Macro to paste selected data to new book

Since I cannot see your workbook and cannot guess what your criteria for
selecting the sheets to copy from nor the data to copy, I wrote this so that
you can fill in the blanks, so to speak. There are two input boxes that
allow you to enter, first, the sheet name and, second, use the mouse to
select the range to copy. Then a message box will ask you if you have more,
so you can repeat the process until you finish all the sheets in your
workbook. If I had more information on the criteria for doing the copying, I
probably could have avoided using the inputboxes altogether. But this will
save a little effort.

Sub CpyToNewWB()
Dim myRng As Range
Set wb1 = ActiveWorkbook
Set NewWB = Workbooks.Add
NewWB.SaveAs Filename:="NewBook.xls"
wb1.Activate
AGAIN:
lr = Workbooks("NewBook").Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
mySht = Application.InputBox("Enter name of sheet to copy from.", _
"SHEET NAME", Type:=2)
Set myRng = Application.InputBox("Select the range to copy.", _
"RANGE TO COPY", Type:=8)
x = myRng.Address
Sheets(mySht).Range(x).Copy Workbooks("NewBook").Sheets(1).Cells(lr + 2, 1)
cont = MsgBox("Do you have another range to copy?", vbYesNo + _
vbQuestion, "COPY ANOTHER RANGE?")
If cont = vbYes Then
GoTo AGAIN:
End If
End Sub

When you copy this over, be sure to watch out for line wrap errors.

"tomhelle" wrote:

I need a macro that will enabel me to perform the following function:

1. Paste selected data (particular range of cells) from worksheet A
(residing in workbook A) to a new Book 1 worksheet.
2. Paste selected data (particular range of cells) from worksheet B
(residing in workbook A) to the same Book 1 worksheet. This data will be
pasted on the next available empty row below the data in step 1.
3. Continue to paste data from worksheet 3 (and on) to next available row in
Book 1.

Thanks in advance for your help!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to copy & paste-special-values data to selected worksheets tomhelle Excel Discussion (Misc queries) 1 May 5th 10 02:00 PM
automate a cut and paste of data from one work book to another Ian Anderson Excel Discussion (Misc queries) 2 May 30th 06 07:59 PM
I wish automate a cut and paste of data from one work book to ano Ian Anderson Excel Worksheet Functions 2 May 28th 06 08:28 AM
Importing Selected Source Book Data Greyson Excel Discussion (Misc queries) 3 December 20th 05 03:02 PM
Create new book..paste data..save..close [email protected] Excel Programming 1 September 12th 05 12:27 AM


All times are GMT +1. The time now is 01:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"