+ Reply to Thread
Results 1 to 22 of 22

Macro to download data from two tables to one excel sheet

  1. #1
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Macro to download data from two tables to one excel sheet

    Hi,

    I have a problem.
    I have a vba macro to download data from one table in excel sheet to new excel file.

    Please Login or Register  to view this content.
    Now in first file I have two tables in the same sheet i I need to have macro to download both tables in one new excel file in one spreedsheet.

    I tried to create similar macro

    Please Login or Register  to view this content.
    but I dont know how to connect this two macros in one.
    Could you please help me?
    thanks in advanced
    N.
    Last edited by nawalanek1; 03-07-2023 at 12:11 PM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,434

    Re: Macro to download data from two tables to one excel sheet

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. 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, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then 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

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Re: Macro to download data from two tables to one excel sheet

    Thanks Glenn for your clarification.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,434

    Re: Macro to download data from two tables to one excel sheet

    Thread open again... Thanks!!

  5. #5
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: Macro to download data from two tables to one excel sheet

    see if this works

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Re: Macro to download data from two tables to one excel sheet

    Thanks k1dr0ck,

    Unfortunately not works.
    Please find attached screenshot with error.
    Br
    N.Attachment 8207012.JPG

  7. #7
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: Macro to download data from two tables to one excel sheet

    try

    Please Login or Register  to view this content.
    Last edited by k1dr0ck; 03-08-2023 at 09:16 AM.

  8. #8
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Re: Macro to download data from two tables to one excel sheet

    Hi k1dr0ck
    Please check attached example.
    When I click button Generate I see data from Table 2 in separate excel file.
    My goal is how to have a both tables( 1 and 2) in this excel file.
    Thanks for your help!
    Br
    N.
    Attached Images Attached Images
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: Macro to download data from two tables to one excel sheet

    see post #7

  10. #10
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Re: Macro to download data from two tables to one excel sheet

    Unfortunately Attachment 820764

  11. #11
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Re: Macro to download data from two tables to one excel sheet

    Hi,
    k1dr0ck
    sorry for confusing date. I know error. One from two tables from original file is Pivot table - this is the reason that macro is showing only one table.
    Is it possible to correct this macro if it works with one table and one pivot table?

    apologies again
    Br
    N.

  12. #12
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: Macro to download data from two tables to one excel sheet

    in your attached there are two tables already, if you link the button to my sub procedure it will copy the two tables to another new workbook, it will look for "Table1" first copy then paste to new workbook then look for the next table, is that what you wanted?

  13. #13
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Re: Macro to download data from two tables to one excel sheet

    yes but one of this tables is pivot table. Macro is downlead only Table 2, pivot table not. I want to download both tables.
    Please check attached file.
    Attached Files Attached Files

  14. #14
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: Macro to download data from two tables to one excel sheet

    try
    it will copy the tables first then the pivot tables

    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Re: Macro to download data from two tables to one excel sheet

    works properly, Thanks!

    PS. Is it possibly to have in resulting file data from pivot table in regular table ? not pivot. - macro copy data from Pivot table and put this data to regular(not pivot) table?
    Last edited by nawalanek1; 03-09-2023 at 08:56 AM.

  16. #16
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Re: Macro to download data from two tables to one excel sheet

    in attach to above post. Attachment 820963
    Attachment 820964

  17. #17
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: Macro to download data from two tables to one excel sheet

    try

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Re: Macro to download data from two tables to one excel sheet

    works
    last question, is it possible to keep cells formatting from original file?
    ex. in original file value is 50% in final file 0,50.

  19. #19
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: Macro to download data from two tables to one excel sheet

    unfortunately the code paste the pivot table as values to convert it to a regular table
    maybe someone has knowledge to convert a pivot table to a regular table and retain formatting

  20. #20
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Re: Macro to download data from two tables to one excel sheet

    ok, Thank you!

  21. #21
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2405-17628.20102
    Posts
    1,404

    Re: Macro to download data from two tables to one excel sheet

    I have been playing with other ways to merge tables and pivot table data etc. It will not help you with your formatting issue as the below will also create values only and not carry any formatting over. Thought i would share what i had been playing with:
    Please Login or Register  to view this content.
    If things don't change they stay the same

  22. #22
    Registered User
    Join Date
    01-22-2022
    Location
    Rzeszów,Poland
    MS-Off Ver
    365
    Posts
    38

    Re: Macro to download data from two tables to one excel sheet

    Thanks CheeseSandwich!
    br
    N.

+ 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. Automatically download web data to excel sheet
    By Bdozer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-31-2016, 06:39 PM
  2. Replies: 0
    Last Post: 01-15-2016, 09:20 AM
  3. Macro to download tables from multiple webpages
    By newbieatexcel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-02-2015, 02:23 AM
  4. macro to Create 3 tables from tables in the attached sheet
    By irfanparbatani in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-12-2015, 08:13 AM
  5. Data Download through Excel Macro
    By vilasc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-18-2012, 09:50 AM
  6. Need a dynamic macro to copy number of tables from a sheet in Excel to Word document
    By padashri in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2012, 02:45 AM
  7. Download data from Web to Excel using VBA Macro
    By nishesh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-24-2011, 07:52 PM

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