Results 1 to 4 of 4

VBA to highlight range and format as a table

Threaded View

  1. #1
    Registered User
    Join Date
    07-22-2008
    Location
    WV
    Posts
    70

    VBA to highlight range and format as a table

    How to fix this VBA macro so it would highlight a range like A1 to the last row of column N and then format it as a table.
    The number of rows will always vary, so I can’t name specific row number but I also don’t want more rows than required so I just want it to go to the last row in column N that has data in a cell.

    Sub MakeTable()
        Dim tbl As ListObject
        Dim rng As Range
    
        Set rng = Range("A1:A" & LastRowColumnN)
        Set tbl = ActiveSheet.ListObjects.Add(xlSrcRange, rng, , xlYes)
        tbl.TableStyle = "TableStyleMedium15"
    End Sub
    I’ve tried the following, but I know nothing about VBA. I just found a similar one online and attempted to modify it for my needs, but I get a runtime error.
    Last edited by jambog; 02-11-2021 at 04:10 PM. Reason: added code tags

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: 08-22-2019, 07:18 PM
  2. [SOLVED] Conditional Format to highlight cells in a range if any have an entry
    By Stryfe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-28-2018, 02:50 PM
  3. Replies: 1
    Last Post: 12-19-2017, 06:50 AM
  4. Replies: 10
    Last Post: 12-11-2016, 08:01 AM
  5. Replies: 3
    Last Post: 05-20-2015, 07:03 AM
  6. [SOLVED] conditional format to highlight values out of range
    By Excel_learner in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-10-2015, 10:34 PM
  7. Replies: 6
    Last Post: 06-29-2013, 03:56 PM

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