+ Reply to Thread
Results 1 to 15 of 15

vba code to convert 'n' number of dataset into tables automatically.

  1. #1
    Registered User
    Join Date
    08-06-2014
    Location
    Pune, India
    MS-Off Ver
    2010
    Posts
    84

    Thumbs up vba code to convert 'n' number of dataset into tables automatically.

    Hi All,
    I have series of dataset as output from ERP system.
    for eg dataset as
    A10: R13
    A17: P33
    A36:I39

    The number of rows and columns in each dataset is not fixed.
    I want each dataset to be converted into seperate tables automatically.
    The first dataset always start in cell A10. All the dataset has one thing in common and that is each dataset's first row has same fill color (Interior Color Index= 10921638)

    Thanking for your support in advance.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: vba code to convert 'n' number of dataset into tables automatically.

    Something like:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    08-06-2014
    Location
    Pune, India
    MS-Off Ver
    2010
    Posts
    84

    Thumbs up Re: vba code to convert 'n' number of dataset into tables automatically.

    Hi Olly,
    Is it possible to skip one row and then convert dataset into table.
    Because for example dataset starting from A10 has title say "Incomplete PO" in cell A9. With this code table is created from cell A9 itself.

    Thanking you for your support in advance.

  4. #4
    Registered User
    Join Date
    08-06-2014
    Location
    Pune, India
    MS-Off Ver
    2010
    Posts
    84

    Re: vba code to convert 'n' number of dataset into tables automatically.

    Hi Olly,
    Is it possible to neglect the one row above each datasource.
    The problem is that if datasource starts from cell A10 but it has title in cell A9 say "Incomplete PO".
    With this code table is created from cell A9 which actually should commence from Cell A10.
    Waiting for your reply.
    Thankink for your support in advance.

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: vba code to convert 'n' number of dataset into tables automatically.

    So you want to ignore the first row of EVERY used region, but make a table from the remaining rows?

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-06-2014
    Location
    Pune, India
    MS-Off Ver
    2010
    Posts
    84

    Re: vba code to convert 'n' number of dataset into tables automatically.

    Hi Olly,
    Thank You very much for your valuabel inputs and time.
    I am attaching sheet (130951_1.xls) as I get it as output from ERP system.
    My intention is to convert each datasource in separate table.
    As conveyed number of rows and column in each data source varies from project to project.
    The table must have row filled with gray interior color as header row and all rows highlighted in yellow color as data in that table.
    The row header that is gray colored row is same as I get it from ERP report.I have intentionaaly filled rest of the rows with yellow color.

    Appreciate your valuable time and inputs once again.
    Attached Files Attached Files

  7. #7
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: vba code to convert 'n' number of dataset into tables automatically.

    Your attached file is not an Excel format workbook, and doesn't work.

  8. #8
    Registered User
    Join Date
    08-06-2014
    Location
    Pune, India
    MS-Off Ver
    2010
    Posts
    84

    Re: vba code to convert 'n' number of dataset into tables automatically.

    Hi Olly,
    Please find revised attachment.
    Inconvinience is regretted.
    Attached Files Attached Files

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: vba code to convert 'n' number of dataset into tables automatically.

    Try:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-06-2014
    Location
    Pune, India
    MS-Off Ver
    2010
    Posts
    84

    Thumbs up Re: vba code to convert 'n' number of dataset into tables automatically.

    Hi Olly,
    Thank You.
    The code works perfectly.
    Once again Thank You very much.

    Is it possible to activate the "Total Row" property of each table created by this code using vba coding. This would help user to select the required function, say count or sum based on heading of table in that column ?

  11. #11
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: vba code to convert 'n' number of dataset into tables automatically.

    To enable the Total Rows, change the following:
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    08-06-2014
    Location
    Pune, India
    MS-Off Ver
    2010
    Posts
    84

    Thumbs up Re: vba code to convert 'n' number of dataset into tables automatically.

    Hi Olly,
    I have attached both raw and formatted file using macro with total rows.
    Few of the dataset are not converted to table (titles of such dataset are highlighted in yellow color).
    In few data sets rows are distorted which I have highlighted in red color.
    Please help me to fix this one.

    Thanking you for your support in advance.
    Attached Files Attached Files

  13. #13
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: vba code to convert 'n' number of dataset into tables automatically.

    Adding the Totals Row to each table shifts cells down, below that table. This is causing your tables to misalign, when the column count is different in lower tables.

    Amended code to correct this:
    Please Login or Register  to view this content.
    Note that some of your table headers will still be slightly wrong, as you have some merged cells in your original data. Stop using merged cells. They're horrible!


  14. #14
    Registered User
    Join Date
    08-06-2014
    Location
    Pune, India
    MS-Off Ver
    2010
    Posts
    84

    Re: vba code to convert 'n' number of dataset into tables automatically.

    Hi Olly,
    Thank You Very much. The code works and data is now not misaligned.
    Once again Thank You very much. Sorry to get back to you after some time.

  15. #15
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: vba code to convert 'n' number of dataset into tables automatically.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. You can also thank someone for posts which were helpful by clicking the "* Add Reputation" button to the lower left of those posts. Thanks.

+ 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: 3
    Last Post: 08-16-2013, 01:13 AM
  2. [SOLVED] Automatically convert number to percentage
    By mijam in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-22-2013, 07:20 PM
  3. Convert Number into Word automatically, easy steps
    By kamalpranav in forum Excel General
    Replies: 0
    Last Post: 12-19-2011, 01:03 PM
  4. Code That will Automatically convert a cell's text to Capital...
    By Mhz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-27-2007, 10:57 AM
  5. how to automatically convert a number to words in Excel
    By Anil-HML in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-08-2005, 11:10 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