VBA-copy paste values only-copy until last cell of range

jasleentatlay

New Member
Joined
Mar 8, 2019
Messages
2
I am trying to use following VBA code to copy and pastevalues only.I want to modify it where code can automatically find last cellused (this case I mentioned A1:D29 I would want system to find on its own.

Please advise.


Sub TransferValuesOnly()

Dim rng As Range
Set rng = Workbooks("Book1.xlsx").Worksheets(4).Range("A1:D29")


Workbooks("Mastertemplate.xlsx").Worksheets(3).Range("A7").Resize(rng.Rows.Count,rng.Columns.Count).Cells.Value = rng.Cells.Value

End Sub


 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,471
So you need to create a variable "LR" to be determined by code of the last non-empty cell in Column D? - than assign that to the last cell in your range?
 

Watch MrExcel Video

Forum statistics

Threads
1,108,624
Messages
5,523,968
Members
409,547
Latest member
AW2020

This Week's Hot Topics

Top