+ Reply to Thread
Results 1 to 9 of 9

VBA to Import from another workbook

  1. #1
    Registered User
    Join Date
    01-29-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    94

    VBA to Import from another workbook

    Hi all,

    I think I might have bitten off more than I can chew.
    I have been on the internet for the last few weeks trying to work out how to have VBA,
    Open a file,
    Select a Dynamic range in a worksheet
    then copy the contetent minus the headers into the original worksheet at the last Row
    keeping the formatting of the original worksheet.

    I have been using the VBA made by Ron de Bruin http://msdn.microsoft.com/en-us/libr...ffice.12).aspx it almost will do everything except put the data in the host file.

    Rons VBA is way too advanced for me I need a button that will run the code in Sheet1 and all the data to be stored in the issues tab from any imported workbook.
    Attached Files Attached Files
    Last edited by v2jtb; 01-29-2012 at 06:47 PM.

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: VBA to Import from another workbook

    Can you upload a sample workbook that you are trying to import - is it just one sheet from the workbook you want to import? Does the data get imported into Sheet 1 of the target workbook (the workbook with the macro) or in to the Issues Sheet - if it is going into the issues sheet I assume the workbook you are importing is in a similar structure. You have code to select a file so you can browse for the file you just need to copy the range of data and then paste it into the Issue Sheet? This is pretty straight forward. If you could just post a sample workbook that you want to import with no sensitive data/private data - a dummy workbook - the code to do the import is very straight forward.
    Hope this helps.
    Anthony
    “Confidence never comes from having all the answers; it comes from being open to all the questions.”
    PS: Remember to mark your questions as Solved once you are satisfied and rate the answer(s) questions.”

  3. #3
    Registered User
    Join Date
    01-29-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    94

    Re: VBA to Import from another workbook

    Hi smuzeon,

    Thank you for your reply.

    The imported data will go into the issues log tab at the bottom and is the same type of data that is in the tab.


    Many thanks
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: VBA to Import from another workbook

    What I actually wanted was a small sample of the file you are IMPORTING. I am not sure if you are auto-incrementing Column B as new data comes in - I need to see the file containing the data you are importing. I understand you want to browse to a file and then import that data but unless I know the format of the data in the file you are importing it is fairly difficult to write the code. Can you just upload a sample workbook containing the file you want to import just with a few lines of how the data appears and this will ensure that the imported data goes into the correct columns.
    Anthony

  5. #5
    Registered User
    Join Date
    01-29-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    94

    Re: VBA to Import from another workbook

    Hi Anthony,

    I have attached the data sheet.

    Thank you
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: VBA to Import from another workbook

    Are you sure you uploaded the correct file. In the JB-RonG-data file there are columns A-T and have headings of A, B, ID D,H, RA etc. In the data.xlsx file there are only Columns A-I in a tab called Lessions learned. I have no idea which column of data is to go into the JB-RONG data file - you will need to map the copy for me e.g. Column A in data file goes into Column C of JB-RonG file - there is just no correlation between the data file you uploaded and the JB-RONG file. You will need to be specific about which column goes where. As well in the data file in COlumn D and Column I it is just full of recurring sentences.
    Could you check you uploaded the correct file -
    The imported data will go into the issues log tab at the bottom and is the same type of data that is in the tab.
    The data you uploaded certainly is not of the same data type. Could you check this for me please.

    Anthony
    “Confidence never comes from having all the answers; it comes from being open to all the questions.”

  7. #7
    Registered User
    Join Date
    01-29-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    94

    Re: VBA to Import from another workbook

    Sorry I don't know how to delete this post.
    Attached Files Attached Files
    Last edited by v2jtb; 02-01-2012 at 04:45 PM.

  8. #8
    Registered User
    Join Date
    01-29-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    94

    Re: VBA to Import from another workbook

    Hi Anthony.
    I have added the final imported document with the original dark blue heading and the light blue data if this helps?
    My assumption was that the data would be thrown into the issues log tab at the bottom and each set of data would go at the bottom.
    The columns I thought would be sorted or changed to accommodate either the issue I have is pasting into the form. I am Not too fussed as to the order.
    Many thanks and sorry for the trouble.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    01-29-2010
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    94

    Re: VBA to Import from another workbook

    Sorry I don't know how to delete this post.

  10. #10
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: VBA to Import from another workbook

    I have attached the workbook for you - There is the button you placed on the first sheet - this is attached to the code. This will allow you to browse to the data file you want to import then it will import the data to the Issues Log worksheet and then close the data file. When you go to import your next data file it will be appended to the existing data on the Issue Log sheet. If there are any problems or questions just let me know

    Hope this helps.
    Anthony
    “Confidence never comes from having all the answers; it comes from being open to all the questions.”
    PS: Remember to mark your questions as Solved once you are satisfied and rate the answer(s) questions.”
    Attached Files Attached Files

  11. #11
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: VBA to Import from another workbook

    I have uploaded the latest file - The server timed out so I have attached the file again just in case the last version was corrupt
    Hope this helps.
    Anthony
    “Confidence never comes from having all the answers; it comes from being open to all the questions.”
    PS: Remember to mark your questions as Solved once you are satisfied and rate the answer(s) questions.”

  12. #12
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: VBA to Import from another workbook

    -server error

+ 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