+ Reply to Thread
Results 1 to 15 of 15

VBA for sheet formatting

  1. #1
    Forum Contributor
    Join Date
    07-14-2019
    Location
    Dubai
    MS-Off Ver
    2019
    Posts
    695

    VBA for sheet formatting

    Hello

    I have set of queries tables in same sheet in same columns range
    Looking to have code in sheet activate event after refresh all queries to add title for each table and formatting:
    1 - for each table in sheet, add one row above the table header
    2 - Write in the new row, the name of the table in excel
    3 - formatting the new row, merge B:D and text alignment center across selecting, Black Bold font, row height 30

    there is result sample in the attachment
    note: the code should work even if I add or delete a table
    Attached Files Attached Files

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,501

    Re: VBA for sheet formatting

    Hi Undo,

    Try below code ...
    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  3. #3
    Forum Contributor
    Join Date
    07-14-2019
    Location
    Dubai
    MS-Off Ver
    2019
    Posts
    695

    Re: VBA for sheet formatting

    Good Job!
    I face one problem and the title will duplicate when I reopen the sheet few times, solution is to delete entire row above the table header before update queries (only first row above the header)
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    1,334

    Re: VBA for sheet formatting

    A little different
    Please Login or Register  to view this content.
    Artik

  5. #5
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    1,334

    Re: VBA for sheet formatting

    Next modification:
    Please Login or Register  to view this content.
    Artik

  6. #6
    Forum Contributor
    Join Date
    07-14-2019
    Location
    Dubai
    MS-Off Ver
    2019
    Posts
    695

    Re: VBA for sheet formatting

    Only this is the different ?
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    1,334

    Re: VBA for sheet formatting

    No.
    Look harder.

    Artik

  8. #8
    Forum Contributor
    Join Date
    07-14-2019
    Location
    Dubai
    MS-Off Ver
    2019
    Posts
    695

    Re: VBA for sheet formatting

    Cool!
    I am trying to do this, but its says error 424 object required
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    1,334

    Re: VBA for sheet formatting

    You should use RowHeight, not Height.

    Artik

  10. #10
    Forum Contributor
    Join Date
    07-14-2019
    Location
    Dubai
    MS-Off Ver
    2019
    Posts
    695

    Re: VBA for sheet formatting

    Great Work!
    Last edited by Undo; 06-24-2022 at 09:47 AM.

  11. #11
    Forum Contributor
    Join Date
    07-14-2019
    Location
    Dubai
    MS-Off Ver
    2019
    Posts
    695

    Re: VBA for sheet formatting

    What If I want write query table name rather than table name?

  12. #12
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    1,334

    Re: VBA for sheet formatting

    Maybe
    Please Login or Register  to view this content.
    Artik

  13. #13
    Forum Contributor
    Join Date
    07-14-2019
    Location
    Dubai
    MS-Off Ver
    2019
    Posts
    695

    Re: VBA for sheet formatting

    Cool!
    its get the query name but its write before the name "Query - "
    mean if the query name "T1" its paste Query - T1"
    Kindly remove "Query - "

  14. #14
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    1,334

    Re: VBA for sheet formatting

    Perhaps, just change the content of the function:
    Please Login or Register  to view this content.
    Artik

  15. #15
    Forum Contributor
    Join Date
    07-14-2019
    Location
    Dubai
    MS-Off Ver
    2019
    Posts
    695

    Re: VBA for sheet formatting

    Thanks Again!

+ 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: 07-21-2020, 02:07 AM
  2. [SOLVED] Cell Formatting Lost on Source Sheet When Pasting to Another Sheet
    By Jim Clayton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-17-2018, 10:38 AM
  3. Macro to copy conditional formatting rules from sheet to sheet.
    By namy77 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2017, 11:38 AM
  4. Replies: 9
    Last Post: 05-13-2013, 05:43 AM
  5. Formatting cells in one sheet based on their values in another sheet
    By bwlodarczyk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2012, 11:07 AM
  6. Replies: 2
    Last Post: 10-28-2010, 11:15 AM

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