• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to paste data after the previous data

A9kurs

New Member
Hi Guys,

I am trying to make a VBA macro my objective is that when i click on button it will ask me for excel file and when i select file than it paste the data and again ask for another file and paste the data after the existing data .
I am done with first where user select the file and paste the data from selected file but i am stuck where user selects second file and my code is overlapping the existing data. Please look into attachment.

Thanks
 

Attachments

  • Dummy.xlsm
    176.1 KB · Views: 9
Hi !​
Post the code with code tags or just using the icon in the 3 dots arrow down menu …​
If the first row is row #1 then use the Count property of the Rows of the UsedRange property of the worksheet.​
 
Hi !​
Post the code with code tags or just using the icon in the 3 dots arrow down menu …​
If the first row is row #1 then use the Count property of the Rows of the UsedRange property of the worksheet.​
Code:
Sub GetFileCopyData1()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim Fname As String
Dim SrcWbk As Workbook
Dim DestWbk As Workbook
Set DestWbk = ThisWorkbook
Fname = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls*", Title:="Select a File")
If Fname = "False" Then Exit Sub
Set SrcWbk = Workbooks.Open(Fname)
SrcWbk.Sheets("Planned Inventory Transactions_").Range("A:X").Copy DestWbk.Sheets("Planned Inventory Transactions_").Range("A:X")
SrcWbk.Close False
Call Fill_Down
Call CopyPaste
End Sub

Why did You copy two times same code ... and without code -tags?
Deleted the 1st copy.
 
Last edited by a moderator:
it says We cant paste because the copy area and paste are not same
Try with only the upper left cell in the Destination parameter of the Range.Copy method …​
If the issue remains with same error message so in this case check the layout of each worksheet.​
Try manually. As merged cells can be a mess …​
 
Back
Top