+ Reply to Thread
Results 1 to 12 of 12

Import CSV File from web in sheet for each cell value and name sheettab accordingly

  1. #1
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    271

    Import CSV File from web in sheet for each cell value and name sheettab accordingly

    Background: Excel 2003
    Sample file attached herewith.
    Cell D1, has working date, immediate preceding today.
    Based on G1 value, past 'n'days, date in Cell B1 (D1-G1) is worked out again to have working day(not weekends).
    So, we will have From Date (B1) TO Date (D1) Range for data selection.

    Cell A4, A5,A6 would have distinguisher for which data has to be pulled from a website within above date range limit.

    Cell B4, B5,B6 and so on in Column B, would generate dynamic web URL based on Cell A4,A5,A6 in combination with DATE range given above. (Sample URL given).

    If this is done on screen, the screen would appear as given in the attached excel, with option to download these data in CSV format.

    Query/Help sought:
    Now, I want a VBA Macro that could import the CSV file in separate sheet, rename it to the corresponding Cell value, say A4, if already does not exist. If Sheet with name Cell A4 already exisit, macro should first clear all data, and then import the data specified above.

    Thanks
    Attached Files Attached Files
    Last edited by analystbank; 03-03-2015 at 06:48 AM. Reason: proper titling

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Import CSV File from web in sheet for each cell value and name sheettab accordingly

    Hello analystbank,

    The macro below will create a new sheet if needed or overwrite data on an existing sheet. A button has been added to "Sheet1" to run the macro.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    271

    Re: Import CSV File from web in sheet for each cell value and name sheettab accordingly

    Thanks for response, but seems something wrong at my end? Nothing comes up, and data downloaded by you in one of the sheet also gets cleared.

    do I need to activate, any of the Library in References? I'm using Excel2003 version.

    What is the trick, if i want to add further Rows in Sheet1, Say A7, A8, and so on, and have corresponding Sheets separately to have data, in respective sheets?
    Last edited by analystbank; 03-04-2015 at 02:11 AM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Import CSV File from web in sheet for each cell value and name sheettab accordingly

    Hello analystbank,

    You don't need to add any libraries to your project. The necessary objects are created using late binding.

    I don't believe running the macro on Excel 2003 should be a problem. What version of Internet Explorer are using?

  5. #5
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    271

    Re: Import CSV File from web in sheet for each cell value and name sheettab accordingly

    I'm having Google Chrome - Version 40.0.2214.115 m

  6. #6
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    271

    Re: Import CSV File from web in sheet for each cell value and name sheettab accordingly

    Here is the error screen shot

    Coincidentally, yesterday only my system was replaced. I now have Internet Explorer 11, Win8 Operating system with Office 2013. But the given excel was in Office 2003 version.

    You appear to have successfully downloaded the data. Kindly guide me, since it is not working at my end. Sometime, above error comes, or else macro just gets executed, but no data is found in the respective sheets!!! Please help.
    Last edited by analystbank; 03-05-2015 at 05:36 AM.

  7. #7
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    271

    Re: Import CSV File from web in sheet for each cell value and name sheettab accordingly

    Any Suggestion/Guidance? such a nice code, not getting executed!!!

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Import CSV File from web in sheet for each cell value and name sheettab accordingly

    Hello analystbank,

    This is a major game changer. Windows 8 does not play well VBA. The preferred language with Windows 8 is VB.net. You could also be experiencing problems due to OS bit size. This macro code is written for 32 bit OS. Your system installation may be 64 bit only with no support for 32 bit. You need to find out which you have.

  9. #9
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    271

    Re: Import CSV File from web in sheet for each cell value and name sheettab accordingly

    Yes Sir, you rightly spotted. It is Win8 with 64 bit. But at home, I still have OS as WinXP, and Office 2007. But, there also it does not get executed.

    You have nicely coded the thing, but am still unable to make use of it. any tradeoff possible? Please.

    Simply from a user defined dynamic, date range based url, i need to pull data in excel sheet, and remove the query table for further data research, and manipulation in same sheet.

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Import CSV File from web in sheet for each cell value and name sheettab accordingly

    Hello Hello analystbank,

    The code works on either of my machines. One is Windows XP running Office 2003 and the other is running Windows 7 64 bit with 32 bit support and Office 2010.

    What happens when you trying running the code at home?
    Have you enabled Excel to run VBA macros in the Trust Center settings?
    Does the workbook load?
    Do you get an error messages?

  11. #11
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    271

    Re: Import CSV File from web in sheet for each cell value and name sheettab accordingly

    Sir,

    1) On Win8 Office 2013 - Macro just gets executed, but I dont find any data in respective sheets. No Error at the time of macro processing, and No Result (Output)

    2) On WinXP, Office 2007 - I get Error message (Compile Error - Cant Find Object or Library ) at line

    Please Login or Register  to view this content.
    HTML Code: 
    I dont understand, what to do
    Last edited by analystbank; 03-13-2015 at 01:04 AM.

  12. #12
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    271

    Re: Import CSV File from web in sheet for each cell value and name sheettab accordingly

    What i realise, looking at URL, if it is under 95 characters (String can store upto 255 characters), url properly brings in the data from a CSV file on net, but where it (URL) exceeds 95 characters, it gives error that, such file may not exist on the server.

    Any suggestion, help, please.

+ 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. Replies: 6
    Last Post: 08-10-2014, 03:50 AM
  2. Import text file into excel and split data in specific sheets
    By chirilaionut in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-03-2013, 07:04 AM
  3. Import specific sheets from different file.
    By fatalcore in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2011, 09:44 AM
  4. Using a Range to Change SheetTab
    By JezLisle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2010, 10:54 AM
  5. macro to import specific sheets with value in a file
    By aravindhan_31 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-04-2009, 10:55 AM

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