What is wrong with this Formula? doesnt copy the range determined

daniboymu

Board Regular
Joined
Nov 1, 2020
Messages
54
Office Version
  1. 2019
Platform
  1. Windows
the formula needs to copy the range (A5:DG5) but doesnt do that, just show me random numbers

Sub paste()
' paste2 Macro
Dim lastRow As Long
' this finds the number of the last row
Rows(7) = Cells(Rows.Count, 5).End(xlUp).Row
Range("A5:DG5").Copy
Cells(lastRow + 1, 1).PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("7:7").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I suggest to use

code.png
 
Upvote 0
VBA Code:
Sub paste()
' paste2 Macro
Dim lastRow As Long
' this finds the number of the last row
Rows(7) = Cells(Rows.Count, 5).End(xlUp).Row
Range("A5:DG5").Copy
Cells(lastRow + 1, 1).PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("7:7").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End Sub
 
Upvote 0
Hello dani. Please try this
VBA Code:
Sub paste()
' paste2 Macro
Dim lastRow As Long
' this finds the number of the last row
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A5:DG5").Copy
Range("A" & lastRow + 1).PasteSpecial paste:=xlPasteValues, operation:=xlPasteSpecialOperationNone, _
skipblanks:=False, Transpose:=False

End Sub
 
Upvote 0
Hello dani. Please try this
VBA Code:
Sub paste()
' paste2 Macro
Dim lastRow As Long
' this finds the number of the last row
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A5:DG5").Copy
Range("A" & lastRow + 1).PasteSpecial paste:=xlPasteValues, operation:=xlPasteSpecialOperationNone, _
skipblanks:=False, Transpose:=False

End Sub
Hi! ER_Neha if you could please check this thread, has more details of my problem
 
Upvote 0
How about
VBA Code:
Sub daniboy()
   Rows(7).Insert
   Range("A8:DG8").Value = Range("A5:DG5").Value
End Sub
 
Upvote 0
Hello dani Please try this
VBA Code:
Sub paste2()
' paste2 Macro

Rows("7:7").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A5:DG5").Copy
Range("A" & 8).PasteSpecial paste:=xlPasteValues, Operation:=xlPasteSpecialOperationNone, _
SkipBlanks:=False, Transpose:=False

End Sub
 
Upvote 0
Hello dani Please try this
VBA Code:
Sub paste2()
' paste2 Macro

Rows("7:7").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A5:DG5").Copy
Range("A" & 8).PasteSpecial paste:=xlPasteValues, Operation:=xlPasteSpecialOperationNone, _
SkipBlanks:=False, Transpose:=False

End Sub
THANK YOU SO MUCH NEHA that's exactly what i need!! tyvm!!
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,847
Members
449,194
Latest member
HellScout

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