+ Reply to Thread
Results 1 to 6 of 6

use cell value to open up workbook and copy contents into master sheet

  1. #1
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    use cell value to open up workbook and copy contents into master sheet

    Hello. I have an open workbook, in cell B3 I want to be able to write a month value that will open up a file that I have in a folder and copy all of the contents from the first tab into a tab in the open workbook that is named after the value in B3. The file is in a folder called "GL Import" and the name of the file is "april 2015 - gl detail". So if the value in B3 is april, it will open the file and copy, paste special values, into a new tab called april. Thanks!!

  2. #2
    Registered User
    Join Date
    04-22-2013
    Location
    Philippines & Australia
    MS-Off Ver
    Excel 2016, Office 365
    Posts
    73

    Re: use cell value to open up workbook and copy contents into master sheet

    Just a quick question Do the Tabs named January....December already exist in your Master File

  3. #3
    Registered User
    Join Date
    04-22-2013
    Location
    Philippines & Australia
    MS-Off Ver
    Excel 2016, Office 365
    Posts
    73

    Re: use cell value to open up workbook and copy contents into master sheet

    Mate I have attached a file that might help with your Problem. In order for me to get it to work tho I had to use Data Files without spaces and without "-" in the name. You would need to change the Path references to your path and adjust the ranges from that which I used in this example.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    Re: use cell value to open up workbook and copy contents into master sheet

    Lots of questions:

    1) Why do you have to delete the spaces and the "-"? Not a big deal but just curious.
    2) What is the "file exists" function? How do you create that function in vba?
    3) For your data range, I just want to copy the whole sheet.
    4) The code fails when it gets to set datato= range(MasterData). It says method range of object global failed.

  5. #5
    Registered User
    Join Date
    04-22-2013
    Location
    Philippines & Australia
    MS-Off Ver
    Excel 2016, Office 365
    Posts
    73

    Re: use cell value to open up workbook and copy contents into master sheet

    1. The spaces issue is one I have come across previously and I did find a work around but I cannot recall how, perhaps someone else may know the answer to that
    2. The FileExists is a function in the "Myfunx" module, I use this a lot to check whether a file is present or not
    3. I am not sure how to do the whole sheet with this method, a quick fix is to make sure the range is adequately large enough
    4. MasterData range will include your active workbook name, does this also contain spaces? (Refer to 1. above) .. The FileData will have to have your sheet name, I just used "Data" as a sheet name to test the code

  6. #6
    Registered User
    Join Date
    04-22-2013
    Location
    Philippines & Australia
    MS-Off Ver
    Excel 2016, Office 365
    Posts
    73

    Re: use cell value to open up workbook and copy contents into master sheet

    Found the answer to the Spaces in Names Problem, note the placement of the single quotation characters in the amended code below

    Please Login or Register  to view this content.

+ 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. Macro Problem: Copy contents of cell; search for contents in another workbook
    By jfishstik in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-04-2014, 12:11 PM
  2. How to copy and paste a sheet to a master workbook
    By zohra in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-10-2013, 06:37 AM
  3. Replies: 2
    Last Post: 09-11-2012, 09:42 AM
  4. Macro, copy UNLOCKED cell range of sheet in open workbook to workbook template
    By NicksDad in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-31-2012, 11:18 AM
  5. [SOLVED] Search for heading in data sheet and copy range to corresponding sheet in master workbook
    By sans in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-07-2012, 10:02 AM
  6. Copy Tab from multible open workbooks into 1 Master workbook
    By cooket4 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2012, 11:24 AM
  7. Master Sheet to Open Specific Sheet from a Separate Workbook
    By jennyaccord in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2011, 10:40 AM

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