Copy Paste Values to Last Row

gldurand

Board Regular
Joined
Jun 8, 2006
Messages
178
Office Version
  1. 2016
Platform
  1. Windows
Hi Excel Warriors

I have this VBA code that works fine, but i need to modify it to always copy to LAST ROW. As the criteria changes based on the selection, i am forced to copy all pages of the spreadsheet even if i only have a few entries.

Can anyone assist

Dim extension As String

extension = ".xlsx"

Application.DisplayAlerts = False
Application.CopyObjectsWithCells = False ' Does not copy Macro objects

ActiveSheet.Copy
With ActiveSheet.UsedRange
.Value = .Value
.Validation.Delete ' Removes all Drop Down Lists
End With

Set wbNew = ActiveWorkbook
wbNew.SaveAs ThisWorkbook.Path & "\" & Format(Date, "yyyy-mm-dd") & " " & ActiveSheet.Range("L2") & extension
wbNew.Close True

Application.DisplayAlerts = True
Application.CopyObjectsWithCells = True
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
i am forced to copy all pages of the spreadsheet

Do you want to paste each sheet on the same target sheet?
for example, do you copy sheet1 and paste into sheetX, then copy sheet2 and paste into sheetX but under the previously pasted data?
 
Upvote 0
Its only 1 sheet (Active) in the workbook that I am working with.
 
Upvote 0
Sorry but I don't understand.

ActiveSheet.Copy
What your macro does is copy the entire sheet into a new book.
What do you mean with " but i need to modify it to always copy to LAST ROW. "
 
Upvote 0
there is a drop down in my sheet that lists all the projects for that person. then i copy that to another workbook. But every time i select a new person, the number of projects change. I want to be able to only copy up to Last row. Right now its copying the entire Print Area (6 pages) even though the person might only have 1 page of data

Hope this helps, and thanks for your patience
 
Upvote 0
there is a drop down in my sheet that lists all the projects for that person.
Do you have a macro for that?

You could explain it with some examples, what you have on the sheet, what you put in your drop down list, what you should copy and what you expect as a final result.
 
Upvote 0
there is a drop down in my sheet that lists all the projects for that person.
Do you have a macro for that? You put the macro here.

You could explain it with some examples, what you have on the sheet, what you put in your drop down list, what you should copy and what you expect as a final result.
Use the XL2BB tool to show examples, see my signature.
 
Upvote 0

Forum statistics

Threads
1,215,767
Messages
6,126,773
Members
449,336
Latest member
p17tootie

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