+ Reply to Thread
Results 1 to 9 of 9

How to extract weekly data and create a report using VBAs

  1. #1
    Registered User
    Join Date
    07-09-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    3

    How to extract weekly data and create a report using VBAs

    Hi All!

    This is my first time using VBAs to run a report and I am learning by doing! I will try and explain my problem as clearly as possible...

    I need a macro that will extract data from workbook B and insert it into workbook A, the user will ultimately hit a button on workbook A and activate the macro. I want to run this macro weekly but the name of Workbook B changes weekly.

    I am able to create the macro that extracts the data but I am not sure how to make the name of workbook B dynamic. Is it possible for the user to select the workbook (file) they want to run the macro on within workbook A?

    How do I do this?? appreciate any help or tips.

    Thanks!
    Lana

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,755

    Re: How to extract weekly data and create a report using VBAs

    Add an input box to your macro requesting the file name of your user.

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How to extract weekly data and create a report using VBAs

    Do you have a naming convention for workbook B? How does the name change.

  4. #4
    Registered User
    Join Date
    07-09-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How to extract weekly data and create a report using VBAs

    Thanks Alan, I'll give that a try.

    John - The name changes with the date. i.e. Filename_Date

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How to extract weekly data and create a report using VBAs

    If the date were todays date, something like this may work.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-09-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How to extract weekly data and create a report using VBAs

    Alan - I've tried using your code. Once I have entered the path into the box I run
    Windows("inp").Activate
    This gives a runtime error and the file doesn't open.
    Any ideas why?

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,755

    Re: How to extract weekly data and create a report using VBAs

    Shouldn't the line of code read
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How to extract weekly data and create a report using VBAs

    Shouldn't there be a file extension for workbooks?

    Workbooks("inp.xlsx").activate?

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,755

    Re: How to extract weekly data and create a report using VBAs

    John;
    I agree with you, but based upon OP information when he indicated he had path from input box, I assumed (hopefully correctly) that it was in the variable "inp."

    Alan

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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