JonathanK1
New Member
- Joined
- Mar 18, 2013
- Messages
- 18
I need a macro that will copy data from another spreadsheet and paste it into the current spreadsheet (where the macro is stored). I'm working off of this (below). This opens up the other workbook (and appears to copy) but it's still pasting into a new workbook, which is not what I want.
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
For x = 1 To 17
working.Rows(x).EntireRow.Copy
dumping.Activate
ActiveSheet.Paste <---------------------is this what needs to be changed???
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
Next
Application.CutCopyMode = False
Cells.Sort Key1:=Range("C:C"), Order1:=xlAscending, _
Key2:=Range("Q:Q"), Order2:=xlDescending, Header:=xlYes
End Sub
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
For x = 1 To 17
working.Rows(x).EntireRow.Copy
dumping.Activate
ActiveSheet.Paste <---------------------is this what needs to be changed???
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
Next
Application.CutCopyMode = False
Cells.Sort Key1:=Range("C:C"), Order1:=xlAscending, _
Key2:=Range("Q:Q"), Order2:=xlDescending, Header:=xlYes
End Sub