Macro to Copy to Next Open Row of New Worksheet

DataMgmtAnalyst7

New Member
Joined
Dec 2, 2020
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
I am running a code that copies data for a specific criteria and moves it from one worksheet to a new worksheet (Sheet2). However, I am having an issue where if I run the code a second time for new values then it deletes all the previous data from Sheet2 and copies the new data over. So, I am trying to figure out how I can edit the code so that when it paste the values to Sheet2 it always pastes them in the next available row instead of overwriting the existing data?

VBA Code:
Sub MoveCompleted()
'
'MoveCompleted Macro
'
Dim lastRow As Long
    lastRow = Range("A" & Rows.Count).End(xlUp).Row
    ActiveSheet.Range("$A$1:$AW$" & lastRow).AutoFilter Field:=27, Criteria1:="Yes"
    Range("A1").Select
    Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("A1").Select
    ActiveSheet.Paste
    Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    ActiveSheet.Paste
    Sheets("EFT").Select
    Range("B2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.EntireRow.Delete
    Range("B8165").Select
    ActiveSheet.ShowAllData
    Range("B2").Select
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi & welcome to MrExcel.
How about
VBA Code:
Sub MoveCompleted()
'
'MoveCompleted Macro
'
   Dim lastRow As Long
   lastRow = Range("A" & Rows.Count).End(xlUp).Row
   With ActiveSheet
      .Range("A1:AW" & lastRow).AutoFilter 27, "Yes"
      .AutoFilter.Range.Offset(1).Copy Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
      .AutoFilter.Range.Offset(1).EntireRow.Delete
      .ShowAllData
   End With
End Sub
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top