+ Reply to Thread
Results 1 to 8 of 8

New VBA to Import Data

  1. #1
    Registered User
    Join Date
    09-05-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    22

    New VBA to Import Data

    I am trying to create an Excel Macro that will do the following.
    1. Prompt me to choose another excel sheet to to open and allow me to pick the file using MSO FILE DIALOG OPEN
    2. CLear the contents of the one of the sheets on my workbook("Data")
    3. Take the file that I Choose and copy range A1:1650 and then paste special with formating the cells into the current workbook to sheet("Data")

    Right now I have a Macro that does this except that I have to choose the range with a Input box and I dont want to have to do that. Please see below.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 09-05-2013 at 02:35 PM. Reason: Added CODE tags, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thanks.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: New VBA to Import Data

    Like so:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-05-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: New VBA to Import Data

    What if the sourcebook that is opened has a worsheet name that always changes. How can I have the macro just choose that sheet that will be active when the file is opened instead of putting a worksheet name into the macro?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: New VBA to Import Data

    That's a dangerous approach. But you can replace the workbook.sheet("name") portion of the code with the simple reference to ActiveSheet since it will BE the activesheet once the workbook was just opened.

    Please Login or Register  to view this content.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  5. #5
    Registered User
    Join Date
    09-05-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: New VBA to Import Data

    I am now getting two errors. Please see code below??

    Please Login or Register  to view this content.
    Last edited by Jvollmer33; 09-06-2013 at 01:29 PM.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: New VBA to Import Data

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    I corrected your post #1, now you must do the post above.
    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  7. #7
    Registered User
    Join Date
    09-05-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: New VBA to Import Data

    I am now getting two errors. Please see code below??

    Please Login or Register  to view this content.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: New VBA to Import Data

    I didn't correct any of your RANGE code, A1:1650 is wrong. Perhaps it should be: A1:A1650 or A1:Z1650 ?

+ 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. Import Macro sometimes adding data to end of last import
    By himynameisiain in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2013, 07:06 AM
  2. Replies: 5
    Last Post: 01-16-2013, 12:33 PM
  3. Import web data into excel does not import picture, how to substitute picture for a value
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2012, 03:29 AM
  4. Import External Data doesn't import
    By JakeAy in forum Excel General
    Replies: 7
    Last Post: 01-26-2010, 03:58 AM
  5. [SOLVED] PLEASE!! How can I un-grey the 'Data-Import External Data-Import Data' option ???
    By kirkm in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-08-2006, 05:05 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