PDA

View Full Version : Pasting the contents from one sheet to a row after the last active row on another



Markiepoop
01-28-2017, 11:27 PM
Every month, I have to compile a list of names. I've decided to write a macro for it but have come across a problem: I can't paste the contents from one sheet to one row after the last active row on another sheet.
Could someone help take a look at the code and tell me where I went wrong?


With ActiveWorkbook.Worksheets(1).AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Range("A2:D2" & lRow).CurrentRegion.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy '

Sheets(Sheets.Count).Select
.Range("A" & .Rows.Count).End(xlUp).Offset(2).Select
ActiveCell.Paste

Here is the excel sheet if you are interested in taking a look. What i'm trying to do is to delete all irrelevant columns, separate the two schemes (DX/QQ), make a third sheet, have the QQ be above while the DX a row below the last active row of the QQ personnel.
Appreciate all help i can get. Thanks!
18178

YasserKhalil
01-28-2017, 11:39 PM
Hello
Try these lines at the end of the sub


Sheets(Sheets.Count).Select
Range("A" & Rows.Count).End(xlUp).Offset(2).Select
ActiveSheet.Paste

Markiepoop
01-29-2017, 08:02 PM
That was great. Thanks for the help! I had spent hours trying to figure it out.

May I know why ActiveSheet.Paste works but not ActiveCell.paste? Is ActiveCell.paste an invalid code.

YasserKhalil
01-29-2017, 09:26 PM
Glad I can offer some help
I think ActiveCell.Paste is invalid method although you can refer to the sheet then the cell the paste like that
Sheets("Sheet1").Range("C10").PasteSpecial xlPasteValues
May be Paste directly not allowed when dealing with ranges or cells