+ Reply to Thread
Results 1 to 5 of 5

Using GetOpenFilename with the GetValue function

  1. #1
    Registered User
    Join Date
    08-09-2012
    Location
    indianapolis
    MS-Off Ver
    Excel 2007
    Posts
    8

    Using GetOpenFilename with the GetValue function

    Hello all,

    I'm new to the GetValue function and I'm having a hard time with it. I need to use this function to get data from one sheet and put it into another, but i'd like the macro to ask the user what file they want to import data from.

    This is what i've got so far . . .

    Please Login or Register  to view this content.
    this doesn't work and honestly i'm stuck. Any help would be greatly appreciated!
    Last edited by Cutter; 08-31-2012 at 10:41 PM. Reason: Added code tags

  2. #2
    Forum Contributor wallyeye's Avatar
    Join Date
    05-06-2011
    Location
    Arizona
    MS-Off Ver
    Office 2010, 2007
    Posts
    308

    Re: Using GetOpenFilename with the GetValue function

    This will get you a little further, but I'm not quite sure what you want to do with it:

    Please Login or Register  to view this content.
    The strPath = application.get... will identify the path of the selected file. You have MultiSelect:=True, so it actually returns an array of paths. Your code only seemed to want to work with one, so I just used strPath(1) for the rest of the procedure. I'm not sure what you want to do with the "Budget.xls" and "Weekly Total", they are references to a pre-named workbook and worksheet.

    So, I guess the real question is, what are you trying to accomplish here? Do you want to update the formulas in the workbook you are running the macro from, to point to the selected workbook? Do you want to bring in values from the selected workbook? Do you want formulas to point to yet another workbook?

    First, which workbook do you want to update?
    Second, what do you want to update into the desired workbook, formulas or values?
    Third, if formulas, where should they point to; if values, I would assume you want to bring them in from the Weekly Total sheet?

    Here, I've opened a new instance of Excel, things tend to run nicer when you do this. Then I open the selected workbook, and assign a reference to it (wbkImport). Your routine then looks in row 1, columns 1 to 100 and does the formula/value update. At the end, close the workbook, close the instance of Excel and call it good.

  3. #3
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Using GetOpenFilename with the GetValue function

    @ mike679

    Welcome to the forum.

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

  4. #4
    Registered User
    Join Date
    08-09-2012
    Location
    indianapolis
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Using GetOpenFilename with the GetValue function

    I'm ultimately trying to pull data from the selected file. Each file will have data on tab 1, A1:BJ1 and I need to copy that data to my active workbook into cells starting C2. Each additional run of the macro will need to copy the data into the next free line.

    I'm not sure if the GetValue function is really the best for what I need, but it's the only one that I know. I get confused with the programming because I'm not sure what to make of the Path and Filename when i'm having the user select the specific file or files that the marco will work with. Honestly this project makes me want to pull my hair out but it will literally save me hours so i'm going to see it through. I really appreciate your help Wallyeye.

  5. #5
    Forum Contributor wallyeye's Avatar
    Join Date
    05-06-2011
    Location
    Arizona
    MS-Off Ver
    Office 2010, 2007
    Posts
    308

    Re: Using GetOpenFilename with the GetValue function

    Sorry for the delay, took some time off. Try this:

    Please Login or Register  to view this content.
    It will prompt you for the file to import, find the current last row in the master workbook, open the importing workbook, find the number of rows in it (using column A as an indicator), then copy all the rows and columns at once into the master. Then it closes the workbook, closes the instance of Excel and exits.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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