Reputation: 23
Hi I am trying to copy a set on cells from the last filled column of a particular row to the next column . I am not getting any error but the values are not getting pasted.
my code :
Dim ed As Variant Dim ee As Variant
ed = ActiveSheet.Cells(55, Columns.count).End(xlToLeft).Column
ee = ActiveSheet.Cells(55, Columns.count).End(xlToLeft).Column + 1
ActiveSheet.Range(ActiveSheet.Cells(ed, 55), ActiveSheet.Cells(ed, 68)).Copy ActiveSheet.Range(ActiveSheet.Cells(ee, 55), ActiveSheet.Cells(ee, 68))
Application.CutCopyMode = False
Upvotes: 1
Views: 1661
Reputation: 4356
You've transposed row and column in your copy statement.
Instead of ActiveSheet.Range(ActiveSheet.Cells(ed, 55), ActiveSheet.Cells(ed, 68)).Copy ActiveSheet.Range(ActiveSheet.Cells(ee, 55), ActiveSheet.Cells(ee, 68))
try:
ActiveSheet.Range(ActiveSheet.Cells(55,ed), ActiveSheet.Cells(68, ed)).Copy ActiveSheet.Range(ActiveSheet.Cells(55, ee), ActiveSheet.Cells(68, ee))
But there are a number of better ways to achieve this range copy.
Upvotes: 0