We help IT Professionals succeed at work.

copy and paste the  data from one file to another file

181 Views
Last Modified: 2018-08-26
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
Comment
Watch Question

Roy CoxGroup Finance Manager
CERTIFIED EXPERT

Commented:
Why not just save the sheet to csv?
Excel & VBA Expert
CERTIFIED EXPERT
Most Valuable Expert 2018
Awarded 2015
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Thnx Neeraj Sir & Roy Cox Sir for ur great Support
Roy CoxGroup Finance Manager
CERTIFIED EXPERT

Commented:
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
Roy CoxGroup Finance Manager
CERTIFIED EXPERT

Commented:
Bit of a rush!!
Subodh Tiwari (Neeraj)Excel & VBA Expert
CERTIFIED EXPERT
Most Valuable Expert 2018
Awarded 2015

Commented:
You're welcome Sachin!

Author

Commented:
Thnx Roy Cox Sir for ur great support