Quantcast
Channel: Active questions tagged worksheet-function - Super User
Viewing all articles
Browse latest Browse all 998

VBA - Copy, Paste then delete from old sheet

$
0
0

I have a worksheet that allows a user to pastes data in and then paste it into a hidden sheet in the workbook that drives a pivot table. This is done by command button.

My code selects data in the range until the last row, then pastes it into the next row without data in it in the other worksheet. I am then trying to delete the data from the upload sheet once then has finished. Everything works beside the deletion of the data. Not sure whats wrong. I also tried to use 'Cut' instead of copy, but had the same result. SOme help would be appreciated.

Sub TestingPaste()    Application.ScreenUpdating = False    Dim lst As Long    Sheets("Upload Data").Range(Range("A2:N2"), Range("A2:N2").End(xlDown)).Copy    With Sheets("Test")        lst = .Range("A"& Rows.Count).End(xlUp).Row + 1        .Range("A"& lst).PasteSpecial xlPasteColumnWidths        .Range("A"& lst).PasteSpecial xlPasteValues        Sheets("Upload Data").Range(Range("A2:N2"), Range("A2:N2").End(xlDown)).Clear    End With    Application.ScreenUpdating = TrueEnd Sub

Viewing all articles
Browse latest Browse all 998

Trending Articles