+ Reply to Thread
Results 1 to 4 of 4

Format data as table theme using only the used range

Hybrid View

  1. #1
    Registered User
    Join Date
    09-20-2012
    Location
    Tamaqua, PA, USA
    MS-Off Ver
    Excel 2016
    Posts
    7

    Format data as table theme using only the used range

    What I am trying to accomplish is having some data that looks just plain (tab titled "Before Table Format") end up to look like what is on tab "When Done".
    I'm having issues getting the range selected to be dynamic as this data is never the same number of rows.


    Thanks!
    Attached Files Attached Files
    Last edited by KarenYK; 10-02-2013 at 08:48 AM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Format data as table theme using only the used range

    Hi KarenYK

    Welcome to the Forum!

    Try this
    Option Explicit
    
    Sub Test()
        Dim LR As Long, LC As Long
        Dim ws As Worksheet
    
        Set ws = Sheets("Before Table Format")
        With ws
            LR = .Range("A" & Rows.Count).End(xlUp).Row
            LC = .Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, _
                    SearchDirection:=xlPrevious).Column
    
            With ws.ListObjects
                .Add(xlSrcRange, Range(Cells(9, 1), Cells(LR, LC)), , xlYes).Name = "Table1"
                ws.ListObjects("Table1").TableStyle = "TableStyleMedium2"
            End With
        End With
    End Sub
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    09-20-2012
    Location
    Tamaqua, PA, USA
    MS-Off Ver
    Excel 2016
    Posts
    7

    Thumbs up Re: Format data as table theme using only the used range

    Woot! Woot! It works for me!

    Thank you for your help. I can even use this in a few other processes I have going on.


  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Format data as table theme using only the used range

    You're welcome...glad I could help. Thanks for the Rep.

+ 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] Convert Range of a Pivot Table to R1C1 format
    By Gorilla in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-29-2013, 09:49 AM
  2. reorganizing data from pivot table format to a format more suitable for presentations
    By pwent_1975@yahoo.com in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-12-2013, 01:41 PM
  3. Replies: 3
    Last Post: 10-25-2012, 04:30 PM
  4. Format Theme for weekly data dump
    By neisenbe in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 09-18-2012, 11:04 AM
  5. [SOLVED] Data in Cross-Tab format: needs to be written in Table Format
    By runyan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-04-2005, 03:05 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