+ Reply to Thread
Results 1 to 6 of 6

Read Table Headers and write in another table

Hybrid View

  1. #1
    Registered User
    Join Date
    11-06-2009
    Location
    Paris, France
    MS-Off Ver
    Office 365
    Posts
    19

    Question Read Table Headers and write in another table

    Hi team,
    First, Happy new year and best wishes to all.

    Even progressing in VBA I struggle for long time with the following macro.
    The aim is to read the width of all column of a table, and write them in a table (to be reuse is need to set back the width to what has been previously saved)
    Currently I am able to read the width of each column but not the name of the colum,

    Public Sub RPL_SaveColumnWidths1()
    ' Mise en forme pour la vue Ready RPL
        Dim tRPL As New MGE_Table           'Table of which I read the column width
        Dim tCOL As New MGE_Table          'Table to fill with 3 values per column (Name, Witdh HeaderName)  ex A, 10.5, Customer
        Dim iCol
        
    ' Lecture de  la table
        tRPL.GetTable "DRB"
        tCOL.GetTable "ColWidth1"
    ' Preparation de la table
        tCOL().ClearContents
    ' Lecture des Colonnes
        iCol = tRPL.ColCount - tCOL.RowCount
        If iCol > 0 Then tCOL.AddRow iCol
        For iCol = 1 To tRPL.ColCount
            With tRPL(iCol, 1)
                tCOL(1, iCol) = Split(.Address, "$")(1)
                tCOL(2, iCol) = .ColumnWidth
               ' tCOL(3, iCol) = ("[#Headers]") ' It is here .... where I need help 
            End With
        Next
    End Sub
    About the "GetTable" ClassModule, it has been develop by the man who was working before me and was a real Dev

    Public Sub GetTable(sTableName, Optional oWb = Nothing)
    ' Associates this instance of MGE_Table class with the existing Excel table named sTableName in Workbook oWb (default: ActiveWorkbook).
    
        If oWb Is Nothing Then Set oWb = ActiveWorkbook
        m_sTableRef = Replace(Replace(m_sTableRefPattern _
                    , "WB", oWb.Name) _
                    , "TBL", sTableName)
        
        Set m_oList = Nothing
        On Error Resume Next
        Set m_oList = Range(m_sTableRef).Parent.ListObjects(sTableName)
    End Sub

  2. #2
    Registered User
    Join Date
    11-06-2009
    Location
    Paris, France
    MS-Off Ver
    Office 365
    Posts
    19

    Re: Read Table Headers and write in another table

    No one has any idea ?

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,181

    Re: Read Table Headers and write in another table

    We don't get many Access queries - most members are in to Excel.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    11-06-2009
    Location
    Paris, France
    MS-Off Ver
    Office 365
    Posts
    19

    Re: Read Table Headers and write in another table

    Hi AliGW
    This is purely in Excel (using Table) I do not even know to use ACCESS despite it might be better for me.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,181

    Re: Read Table Headers and write in another table

    OK - well, you posted in the Access sub-forum, which may be why you've had no replies! I'll move this to the Excel VBA section for you.

  6. #6
    Registered User
    Join Date
    11-06-2009
    Location
    Paris, France
    MS-Off Ver
    Office 365
    Posts
    19

    Re: Read Table Headers and write in another table

    Sorry for this error

+ 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. Turning the items in a table column into the headers of another table and auto update
    By Caraexcel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-26-2023, 02:20 AM
  2. Replies: 7
    Last Post: 10-26-2023, 02:20 AM
  3. [SOLVED] Tutorial Needed: User upload xlsx file, read that file, write to table
    By PrimePorkchop in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-30-2021, 10:50 PM
  4. [SOLVED] Read Table Headers to Array
    By lloydgodin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-16-2016, 05:29 PM
  5. Replies: 1
    Last Post: 03-28-2013, 11:31 AM
  6. [SOLVED] Read whole file,Match the headers based on specific condition & write to text file
    By macromaniac in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-07-2011, 06:37 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