Consulting

Results 1 to 6 of 6

Thread: Copy data from another file without opening

  1. #1
    VBAX Regular
    Joined
    Nov 2021
    Posts
    14
    Location

    Question Copy data from another file without opening

    Good morning,
    I have the file "C:\Users\Itaerxga\Desktop\s.xlsx" workbook "data (2)" and I need to copy from "A2: T30000" and I need to paste this "Campione" workbook to A2.
    And must run the vba when opening the file.


    Thanks and best regards
    Attached Files Attached Files

  2. #2
    Assuming that "data(2)" is the worksheet in the workbook on the desktop that you want to copy from
    That the sheet you want to paste the copied data into is "Sheet1" in a workbook named "Campione"
    This goes in the "ThisWorkbook" module of the Workbook you want to paste into (Campione).




    Private Sub Workbook_Open()
    With ThisWorkbook.Sheets("Sheet1").Range("A2:T30000")    '<----- Change as required
        .Formula = "='C:\Users\Itaerxga\Desktop\[s.xlsx]data(2)'!RC"    '<----- Change if required
        .Value = .Value
    End With
    End Sub

  3. #3
    VBAX Regular
    Joined
    Nov 2021
    Posts
    14
    Location
    Good evening,
    Sorry maybe I wrote wrong, basically I have an extracted.xls file with the name "Test" and I'm on cell A2 and I have to copy the file C: \ Users \ Itaerxga \ Desktop \ s.xlsx worksheet "data" A2: T30000.

    And the file should run upon opening.

    Thanks for the help

  4. #4
    What is "an extracted.xls" file?
    Sub Get_Data()
    With ThisWorkbook.Sheets("Sheet1").Range("A2:T30000")    '<----- Change as required
        .Formula = "='C:\Users\Itaerxga\Desktop\[s.xlsx]data'!RC"    '<----- Change if required
        .Value = .Value
    End With
    End Sub
    You say you want data imported without opening workbook.

  5. #5
    VBAX Regular
    Joined
    Nov 2021
    Posts
    14
    Location
    Excuse me
    C:\Users\Itaerxga\Desktop\[s.xlsx]data'! RC


    RC I did not understand what it means? must copy from A2: C30000 UNTIL THERE ARE THE VALUES.


    Thank you

  6. #6
    You have a space before RC. That should not be there. Is the sheet you copy from in the workbook on your desktop named "data" without the double quotations?
    I tried it and it works like a charm.
    Did you copy the code from Post #4 and pasted it in the ThisWorkbook module, saved the workbook and then opened it?
    But why do you say "Without opening"?
    You won't even notice that a file will be opened.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •