Copy from active sheet to on-going list in another sheet

y3tter

Board Regular
Joined
Nov 11, 2012
Messages
147
Could anyone help me with VBA for copying data from active sheet and pasting in the first available row in sheet titled Archive. I'm trying to copy Range A2:G2, paste in the first available row in Archive sheet. Then in the active sheet delete cells D2, F2 and G2.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try this:
Code:
Sub MyCopy()

    Dim ws1 As Worksheet, ws2 As Worksheet
    Dim nr As Long
    
'   Capture sheets
    Set ws1 = ActiveSheet
    Set ws2 = Sheets("Archive")
    
'   Find next available row on Archive sheet (by looking at entries in column A)
    nr = ws2.Cells(Rows.Count, "A").End(xlUp).Row + 1
    
'   Copy data from cells A2:G2 on activesheet to next available row in archive sheet
    ws1.Range("A2:G2").Copy ws2.Range("A" & nr)
    
'   Clear values from D2:G2 on activesheet
    ws1.Range("D2:G2").ClearContents
        
End Sub
 
Upvote 0
Try this:
Code:
Sub MyCopy()

    Dim ws1 As Worksheet, ws2 As Worksheet
    Dim nr As Long
    
'   Capture sheets
    Set ws1 = ActiveSheet
    Set ws2 = Sheets("Archive")
    
'   Find next available row on Archive sheet (by looking at entries in column A)
    nr = ws2.Cells(Rows.Count, "A").End(xlUp).Row + 1
    
'   Copy data from cells A2:G2 on activesheet to next available row in archive sheet
    ws1.Range("A2:G2").Copy ws2.Range("A" & nr)
    
'   Clear values from D2:G2 on activesheet
    ws1.Range("D2:G2").ClearContents
        
End Sub


Works great, one thing though. The first two cells contain a formula, so I get a #REF ! error. Is there a way to get it to paste value?
 
Upvote 0
Try this variation:
Code:
Sub MyCopy()

    Dim ws1 As Worksheet, ws2 As Worksheet
    Dim nr As Long
    
'   Capture sheets
    Set ws1 = ActiveSheet
    Set ws2 = Sheets("Archive")
    
'   Find next available row on Archive sheet (by looking at entries in column A)
    nr = ws2.Cells(Rows.Count, "A").End(xlUp).Row + 1
    
'   Copy data from cells A2:G2 on activesheet to next available row in archive sheet
    ws1.Range("A2:G2").Copy
    ws2.Range("A" & nr).PasteSpecial xlPasteValues
    
'   Clear values from D2:G2 on activesheet
    ws1.Range("D2:G2").ClearContents
        
End Sub
 
Upvote 0
Try this variation:
Code:
Sub MyCopy()

    Dim ws1 As Worksheet, ws2 As Worksheet
    Dim nr As Long
    
'   Capture sheets
    Set ws1 = ActiveSheet
    Set ws2 = Sheets("Archive")
    
'   Find next available row on Archive sheet (by looking at entries in column A)
    nr = ws2.Cells(Rows.Count, "A").End(xlUp).Row + 1
    
'   Copy data from cells A2:G2 on activesheet to next available row in archive sheet
    ws1.Range("A2:G2").Copy
    ws2.Range("A" & nr).PasteSpecial xlPasteValues
    
'   Clear values from D2:G2 on activesheet
    ws1.Range("D2:G2").ClearContents
        
End Sub


PERFECT!!! Thank you so MUCH!
 
Upvote 0

Forum statistics

Threads
1,214,970
Messages
6,122,514
Members
449,088
Latest member
RandomExceller01

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