Consulting

Results 1 to 6 of 6

Thread: A quick copy/paste question

  1. #1
    VBAX Regular
    Joined
    Jan 2008
    Posts
    39
    Location

    Question A quick copy/paste question

    Say I have two files in the same directory (say, C:\Data)
    File 1 is open, File 2 is closed.

    How can I copy say a range of values from sheet 1 of File 1:
    ThisWorkbook.Worksheets(1).Range("A1", Range("A1").End(xlDown))

    to File 2, Sheet 2, Range (from "B2" down)

    without opening File 2?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Using ADO, but much simpler to open it, copy it, and close it.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Jan 2008
    Posts
    39
    Location
    Quote Originally Posted by xld
    Using ADO, but much simpler to open it, copy it, and close it.
    So basically, that is Macro Recorder way of doing things.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Not sure what you mean there?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    as mentioned by XLD the easiest way will be to copy the range, open the file, paste it and close it.
    If you want this to happen "Bedind the scenes" you can use:
    [VBA]
    application.screenupdating = false
    application.displayalerts = false
    'CODE HERE
    application.screenupdating = true
    application.displayalerts = true
    [/VBA]
    Phil J.

  6. #6
    VBAX Regular
    Joined
    Jan 2008
    Posts
    39
    Location
    Quote Originally Posted by PhilJette
    as mentioned by XLD the easiest way will be to copy the range, open the file, paste it and close it.
    If you want this to happen "Bedind the scenes" you can use:
    [vba]
    application.screenupdating = false
    application.displayalerts = false
    'CODE HERE
    application.screenupdating = true
    application.displayalerts = true
    [/vba]
    I have just read this part in the book.
    What I mean by "Recorder way" is copy-open-paste-close.
    Anyway, thanks guys!

Posting Permissions

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