+ Reply to Thread
Results 1 to 9 of 9

Code to copy data from a closed workbook and paste in active workbook using named range.

  1. #1
    Registered User
    Join Date
    10-27-2013
    Location
    Cape Town, South Africa
    MS-Off Ver
    Excel 2013
    Posts
    6

    Code to copy data from a closed workbook and paste in active workbook using named range.

    Good day!

    I have the following code which successfully:
    1. Opens a CSV
    2. Copies a range in the CSV
    3. Pastes values in active workbook
    4. Closes CSV



    However I need the code to open a different CSV each time (based on a named range not a file path).
    Could someone please have a look at the below code and help me in correcting this?

    Thanking you in advance!

    Paul

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Code to copy data from a closed workbook and paste in active workbook using named rang

    You may try:
    Please Login or Register  to view this content.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Code to copy data from a closed workbook and paste in active workbook using named rang

    try this code

    not tested

    Please Login or Register  to view this content.
    hope this will work for u
    Thanks - Naveed
    -----------------------------
    If the suggestion helps you, then Click * to Add Reputation
    To Attach File: Go Advanced>>Manage Attachments>>Add Files (In Top Right Corner)>>SelectFiles>>.........Locate Your File(s)>>Upload Files>>Done (In Bottom Right)
    1. Use [code] code tags [\code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

  4. #4
    Registered User
    Join Date
    10-27-2013
    Location
    Cape Town, South Africa
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Code to copy data from a closed workbook and paste in active workbook using named rang

    Thank you Izandol,

    However the sheet name "QU14022539" needs to come from a cell reference too. ie. Range("Sheet_name")

    This is what i have now which is working.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-27-2013
    Location
    Cape Town, South Africa
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Code to copy data from a closed workbook and paste in active workbook using named rang

    Hi Naveed,

    Your code works perfectly however can you change it to open a specific CSV from a cell reference rather than the dialog box?

    much appreciated,

    Paul



    Quote Originally Posted by Naveed Raza View Post
    try this code

    not tested

    Please Login or Register  to view this content.
    hope this will work for u

  6. #6
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Code to copy data from a closed workbook and paste in active workbook using named rang

    Hi Paul

    would be great if u provide ur sample workbook so that I can give perfect solution

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Code to copy data from a closed workbook and paste in active workbook using named rang

    You may try:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    10-27-2013
    Location
    Cape Town, South Africa
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Code to copy data from a closed workbook and paste in active workbook using named rang

    Thank you both so much for your help!! Really appreciated!
    Izandol, I used your last code. Like a charm!

    Regards,

  9. #9
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Code to copy data from a closed workbook and paste in active workbook using named rang

    Glad I could help you to some extend

    don't forget Add Reputation to members

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Run Macro in closed workbook and copy specific coloumn in active workbook
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-07-2013, 03:43 AM
  2. Copy worksheet from closed workbook into active/existing workbook.
    By rasikvekaria in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2012, 06:55 AM
  3. Code to Read/Copy Data from Closed Wb and Return/Paste in Active Wb
    By AlvaroSiza in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-15-2010, 09:26 PM
  4. Paste data from active workbook to another workbook using code.
    By 2funny4words in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-07-2009, 04:44 PM
  5. Use VBA to copy named range from a closed workbook?
    By Phraedrique in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-17-2009, 09:39 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1