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
 
Glad I could Help. Also Dani the code which Fluff provided is much easy and short, I think you should go for that.
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Glad I could Help. Also Dani the code which Fluff provided is much easy and short, I think you should go for that.
Neha, i am sorry to bother you but could you please setup this vba code here to do the same thing as the one you did, because with this one here the other spreadsheet is also updated.
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
    Cells(lastRow + 1, 1).PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
End Sub
 
Upvote 0
Neha, i am sorry to bother you but could you please setup this vba code here to do the same thing as the one you did, because with this one here the other spreadsheet is also updated.
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
    Cells(lastRow + 1, 1).PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
End Sub
With this code you are trying to paste your data in the last row of your file, which i suppose is 1200 , please kindly share your query again, I didn't understand properly what you are looking for.
 
Upvote 0

Forum statistics

Threads
1,214,387
Messages
6,119,208
Members
448,874
Latest member
Lancelots

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