LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Member
 
Posts: 40
Default Copy, paste to active workbook?

Me again (sorry, I've been posting quite a bit, I know - but I'm almost finished).

Below is the macro I have. When I run it, it opens a spreadsheet in another folder and pulls from it, then opens a new workbook to paste it into. What I'd like to do is have the data paste into the workbook the macro is being run from. So, no new workbook. I'd like it to paste into the current/active workbook, the one with the macro in it (and it would be nice if I could specify the range it pastes into too - starting A5 to Q5, for example.

I think part of the problem is the add part below, but I've replaced it with "active workbook" (and a dozen variations) and it only errors out.

Sub Button6_Click()
Dim TheAnswer As String
Set wb1 = Workbooks.opm (Filename:="blahblahblah.xlsm"
Dim working As Worksheet, dumping As Workbook
Set working = ActiveSheet
TheAnswer = LCase$(InputBox("Enter state below"))
Set dumping = Workbooks.Add <-------------------------is this the problem?
For x = 1 To 17
working.Rows(x).EntireRow.Copy
dumping.Activate
ActiveSheet.Paste
ActiveCell.Offset(1).Select
Next
For x = 1 To working.Cells.SpecialCells(xlCellTypeLastCell).Row
If LCase$(working.Cells(x, 8).Value) = TheAnswer Then
working.Rows(x).EntireRow.Copy
dumping.Activate
ActiveSheet.Paste
ActiveCell.Offset(1).Select
End If
etc etc etc.
 
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
Copy Range from Open Workbook to Active Workbook Forgone Excel Programming 0 July 17th 09 01:46 AM
Copy from active sheet and paste into new sheet using info from cell in active Ingve Excel Programming 3 January 23rd 06 09:57 PM
Colour active row but allow copy / paste [email protected] Excel Programming 3 January 20th 06 10:52 AM
Copy Paste from Active cell briank Excel Programming 3 June 6th 05 11:56 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM


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

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

About Us

"It's about Microsoft Excel"