Copy and Paste Macro

Attycuz

New Member
Joined
Nov 3, 2015
Messages
10
Womdering if you can help me, Macros are not my strongest haha.
This is what I currently have...
function PP() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('A2:D2').activate();
var currentCell = spreadsheet.getCurrentCell();
spreadsheet.getSelection().getNextDataRange(SpreadsheetApp.Direction.DOWN).activate();
currentCell.activateAsCurrentCell();
spreadsheet.setActiveSheet(spreadsheet.getSheetByName('All'), true);
spreadsheet.getRange('A2').activate();
spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();
spreadsheet.getRange('A12').activate();
spreadsheet.getRange('Project!A2:D10').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
spreadsheet.getRange('E2').activate();
currentCell = spreadsheet.getCurrentCell();
spreadsheet.getSelection().getNextDataRange(SpreadsheetApp.Direction.DOWN).activate();
currentCell.activateAsCurrentCell();
currentCell = spreadsheet.getCurrentCell();
spreadsheet.getSelection().getNextDataRange(SpreadsheetApp.Direction.DOWN).activate();
currentCell.activateAsCurrentCell();
spreadsheet.getRange('E2').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
spreadsheet.getRange('A1').activate();
spreadsheet.getActiveSheet().getFilter().sort(1, false);
};

I have 2 tabs 'Project' and 'All", what I want to do is 1 - Select everything in 'Project' tab (Less the headers) (Columns A-D, Rows Unknown) 2 - Copy 3 - Paste at the bottom of 'All' 4 - Copy Formula in Column E in 'All' to the new additions
Please let me know if you can help
Thanks Mark
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
As here it's only an Excel forum section …​
 
Upvote 0
For code tags, see picture.

Try
Code:
Sub Maybe()
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Worksheets("Project")
Set sh2 = Worksheets("All")
    sh1.Range("A1:D" & sh1.Cells(Rows.Count, 1).End(xlUp).Row).Offset(1).Copy sh2.Cells(Rows.Count, 1).End(xlUp).Offset(1)
    sh2.Cells(Rows.Count, 5).End(xlUp).Resize(sh2.Cells(Rows.Count, 4).End(xlUp).Row - sh2.Cells(Rows.Count, 5).End(xlUp).Row + 1).FillDown
End Sub
 

Attachments

  • How To Use Code Tags MrExcel.jpg
    How To Use Code Tags MrExcel.jpg
    50.6 KB · Views: 21
Upvote 0
or

Code:
Sub Maybe_2()
Dim sh1 As Worksheet, sh2 As Worksheet
Dim lr1 As Long, lr2 As Long
Set sh1 = Worksheets("Sheet1")
Set sh2 = Worksheets("Sheet2")
lr1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
    sh1.Range("A2:D" & lr1).Copy sh2.Range("A" & lr2 + 1)
    sh2.Range("E" & lr2 & ":E" & lr1 + lr2 - 1).FillDown
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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