+ Reply to Thread
Results 1 to 4 of 4

VBA how to convert a range to a table in excel 2010

  1. #1
    Registered User
    Join Date
    01-27-2014
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    2

    VBA how to convert a range to a table in excel 2010

    I am relatively new to VBA and am trying to convert a range of data to a table in the same sheet. I receive the following message when I try to run the code as shown below:

    "The worksheet for the table data must be the same sheet as the table being created." The code stops on the third line of the code.

    Sheets("Data Forwards").Select
    ActiveSheet.Range("$A$1:$U$1000").Select
    ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$U$1000"), , xlYes).Name = _
    "Table1"
    ActiveSheet.Range("Table1[#All]").Select
    ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleMedium2"

    I can see that the range is highlighted in the sheet before the code breaks. Any advice would be greatly appreciated.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,486

    Re: VBA how to convert a range to a table in excel 2010

    Suggest you post a sample workbook.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: VBA how to convert a range to a table in excel 2010

    I think perhaps your code is in another sheet? You may try:
    Please Login or Register  to view this content.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  4. #4
    Registered User
    Join Date
    01-27-2014
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: VBA how to convert a range to a table in excel 2010

    Hello Izandol. Your suggestion worked! Many thanks!

+ 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. Please help! Macro with dynamic range and pivot table Excel 2010
    By sassylogo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-24-2013, 10:31 AM
  2. How to Convert Word 2010 doc to Excel 2010 that contains several tables (one macro)
    By theglitch in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2013, 01:36 PM
  3. Convert Text to Numeric Excel 2010 Pivot Table
    By zcheema in forum Excel General
    Replies: 1
    Last Post: 05-17-2012, 04:58 PM
  4. Searching the particular numberfrom excel'2010 table and locate the number in Word'2010
    By jaffirahamed1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-21-2012, 08:09 AM
  5. Replies: 0
    Last Post: 01-27-2012, 10:55 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