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
OneClick.xlsb
BasketOrder..csv
Sachin SinghAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roy CoxGroup Finance ManagerCommented:
Why not just save the sheet to csv?
1
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Please give this a try...
Following code assumes that both the .xlsb and .csv files are saved in the same folder.

Sub SaveSheet5AsCSV()
Dim ws As Worksheet
Dim strFilePath As String, strFileName As String

Application.ScreenUpdating = False
Application.DisplayAlerts = False

strFilePath = ThisWorkbook.Path & "\"
strFileName = "BasketOrder.csv"
Set ws = Sheets("Sheet5")
ws.Copy
ActiveWorkbook.SaveAs strFilePath & strFileName, xlCSV, , , , False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Sheet5 has been saved as csv file successfully.", vbInformation
End Sub

Open in new window

In the attached, click the button called "SaveAs CSV" to run the code.
OneClick.xlsb
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sachin SinghAuthor Commented:
Thnx Neeraj Sir & Roy Cox Sir for ur great Support
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Roy CoxGroup Finance ManagerCommented:
Sorry

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
        ThisWorkbook.Sheets("Sheet5").Copy
        ''// save as csv file, use NOW to add unique identifier
        ActiveWorkbook.SaveAs ThisWorkbook.Path & .PathSeparator & "BasketOrder_" _
                            & Format(Now, "ddmmyyyy hhmm"), xlCSV, False
        ''/// close csv
        ActiveWorkbook.Close

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

Open in new window

OneClick.xlsb
0
Roy CoxGroup Finance ManagerCommented:
Bit of a rush!!
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome Sachin!
0
Sachin SinghAuthor Commented:
Thnx Roy Cox Sir for ur great support
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.