+ Reply to Thread
Results 1 to 7 of 7

Is it possible to Loop through Tables and Copy TableHeader ?

  1. #1
    Forum Contributor
    Join Date
    03-08-2018
    Location
    Denmark
    MS-Off Ver
    2016 for Windows
    Posts
    413

    Is it possible to Loop through Tables and Copy TableHeader ?

    I am trying to loop trough some Tables that have random Headers,

    Please Login or Register  to view this content.
    Just in case, i wraped it as CODE

    But I am stuck in the header part.
    I hope one of you experts know a way to solve this.

    Thanks for having a look

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Is it possible to Loop through Tables and Copy TableHeader ?

    Use .ListObjects properties, e.g.:
    1) .Count
    2) .Name
    3) .HeaderRowRange
    4) .DataBodyRange / .ListRows / .ListColumns / .Range

  3. #3
    Forum Contributor
    Join Date
    03-08-2018
    Location
    Denmark
    MS-Off Ver
    2016 for Windows
    Posts
    413

    Re: Is it possible to Loop through Tables and Copy TableHeader ?

    Thanks porucha

    I am just a simple Newbee in VBA so I don't know what you meen?
    Can you explain please.
    I have put the code I have below so far.


    Please Login or Register  to view this content.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Is it possible to Loop through Tables and Copy TableHeader ?

    Please upload a workbook or a representative cut down copy, anonymised if necessary. It is always easier to advise if we can see your request in its context.

    Show a before and after situation with manually calculated results, explaining which information is data and which is results, and if it's not blindingly obvious how you have arrived at your results some explanatory notes as well.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Contributor
    Join Date
    03-08-2018
    Location
    Denmark
    MS-Off Ver
    2016 for Windows
    Posts
    413

    Re: Is it possible to Loop through Tables and Copy TableHeader ?

    Thanks Richard
    I will do that.

    PW= *DM2285dm2018* (Sheets are protected)
    Module:= TableCode
    Sub:= LoopThroughTables()
    Sheets "BEREGNING" And "TILBUD2"


    1.PNG2.PNG
    Attached Files Attached Files

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Is it possible to Loop through Tables and Copy TableHeader ?

    This is clearly a very complex workbook and I really don;t have the bigger picture. It woudl help if you could explain what you start with and manually add the results you expect to see after the process has completed.



    That said this looks as though it may be esentially a reporting task based on defined input. You appear to be commiting the same mistake that I see time and time again. You are mixing up the two elements of data capture and final reporting. The two require quite different treatments.

    A lot of people start by designing the form that they expect to see as the final report or which at first glance seems the best way of capturing data, and then wonder why it's so difficult to subsequently analyse and summarise or extract information from it. Yours exhibits all those features.


    You should always capture data in a simple two dimensional table and worry about reporting information from it afterwards. Without exception doing this you will always be able to easily obtain management information. Rarely is this the case if you start the other way round.
    You will also throw open the whole wonderful world of the powerful Pivot table functionality.

  7. #7
    Forum Contributor
    Join Date
    03-08-2018
    Location
    Denmark
    MS-Off Ver
    2016 for Windows
    Posts
    413

    Re: Is it possible to Loop through Tables and Copy TableHeader ?

    Thanks for taking a look

    It is a workbook for calculating buiding tasks "Sheet BEREGNING"
    When all the tasks are put in the sheet I want to be able to print out a Offer for the customer.

    I thought I had explained it in the comments in the sub and looking at the picture with comments I hoped it was clear.
    I am shure to make mistakes as I am just starting to learn VBA.
    But I know I will get there in time, a little help getting on the right track will be appreceated

+ 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. [SOLVED] Loop until cell values match then copy, move to next cell and loop and copy again
    By potga in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2016, 08:51 PM
  2. Copy paste loop using multiple tables
    By Goldbadger in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-19-2015, 08:36 AM
  3. VBA Loop, Find, Copy, Repeat Loop
    By sparx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-02-2013, 06:25 AM
  4. [SOLVED] Can't get nested Loop to copy range values from 2 tables working correctly
    By gtol in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2013, 12:01 PM
  5. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  6. Loop through tables
    By worldsphere in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2011, 05:42 PM
  7. Using Hlookup on multiple tables with for..next loop
    By Cerberus in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-30-2010, 04: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