Avatar of Sachin Singh
Sachin Singh
 asked on

copy and paste the data from one file to another file

my 1st file name is OneClick.xlsb  located in C:\Users\user\Desktop
my 2nd file name is BasketOrder.csv located in C:\Users\user\Desktop
my code will be placed in OneClick.xlsb
now what i want copy sheet5 from OneClick.xlsb and paste to BasketOrder.(this is a sheet name in BasketOrder.csv ) of  BasketOrder.csv
(If there is a data in  BasketOrder.csv file then first delete the data then paste the data)
plz see the attached  file
Microsoft OfficeVBAMicrosoft ExcelMicrosoft Applications

Avatar of undefined
Last Comment
Sachin Singh

8/22/2022 - Mon
Roy Cox

Why not just save the sheet to csv?
Subodh Tiwari (Neeraj)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Sachin Singh

Thnx Neeraj Sir & Roy Cox Sir for ur great Support
Roy Cox


Had to nip out. Here's my suggestion

Option Explicit

Sub SaveSheetToCSV()

    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False

        ''/// sheet to copy to csv. Copy will copy the sheet to a new workbook automatically because no workbook is specified
        ''// save as csv file, use NOW to add unique identifier
        ActiveWorkbook.SaveAs ThisWorkbook.Path & .PathSeparator & "BasketOrder_" _
                            & Format(Now, "ddmmyyyy hhmm"), xlCSV, False
        ''/// close csv

        .DisplayAlerts = True
        .ScreenUpdating = True
    End With
    MsgBox "Done", vbInformation
End Sub

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Roy Cox

Bit of a rush!!
Subodh Tiwari (Neeraj)

You're welcome Sachin!
Sachin Singh

Thnx Roy Cox Sir for ur great support
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.