+ Reply to Thread
Results 1 to 8 of 8

Converting a table to a range in order to delete the name

  1. #1
    Forum Contributor
    Join Date
    02-01-2021
    Location
    Manchester
    MS-Off Ver
    365
    Posts
    216

    Converting a table to a range in order to delete the name

    I have a situation where I need to delete a table name. I know that this is not directly possible, but can be achieved by changing the table back to a range and then deleting the range name.
    I need to do this using vba so in order to get a handle on the code I made a table and then ran a macro to delete it.
    When I looked at the macro all it said was " Range ("A3"). Select"
    What I had done was select a cell in the table "A3".
    Clicked Table Design
    Clicked Convert to range.
    Then
    Discovered that the table no longer existed, and had not been replaced by a range name which had given me what I need.
    But no code in the Macro.
    What should I write to get the effect that I need
    Osprey

  2. #2
    Forum Contributor
    Join Date
    02-01-2021
    Location
    Manchester
    MS-Off Ver
    365
    Posts
    216

    Re: Converting a table to a range in order to delete the name

    Further information.
    The reason for wanting to be able to delete a table name is that If I leave it existing ; the following line of code:-
    Please Login or Register  to view this content.
    I get an error "A Table must not overlap another table"
    So as an alternative to getting rid of the name and raising it anew, is there a way of "activating" an existing table, because if I rem out the line above the rest of the code does not recognize the table.
    Osprey

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Converting a table to a range in order to delete the name

    Quote Originally Posted by Osprey2 View Post
    ...changing the table back to a range and then deleting the range name.
    The code below will convert a table to a range, but I do not understand what you mean about deleting the range name. If you convert the table to a range (using this code as well as the manual method you described) the table name is deleted and there is no residual range name.

    Update table name to suit.

    Please Login or Register  to view this content.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Converting a table to a range in order to delete the name

    I posted my solution before I saw your second post. I don't follow what you are trying to do. Can you attach your file and explain what you want to do in terms of what is on the worksheet, rather than lines of code? See yellow banner at the top of the page.

  5. #5
    Forum Contributor
    Join Date
    02-01-2021
    Location
    Manchester
    MS-Off Ver
    365
    Posts
    216

    Re: Converting a table to a range in order to delete the name

    Thank you very much for your interest. I hope the attached workbook will make sense of what I am trying to do.
    Osprey
    Attached Files Attached Files

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Converting a table to a range in order to delete the name

    Your code has this comment after code that looks like what I provided above:
    Please Login or Register  to view this content.
    The reason you are getting the error is that there is no table in the worksheet called "tblOld". In fact there are no tables at all.

    Your code also refers to
    Please Login or Register  to view this content.
    but there is nothing in those cells so the regions are just one cell, and therefore x=1 and y=1. It still doesn't explain your strategy or what you want to happen.

    Unfortunately this file does not explain what you need to do. It shows one group of data, and another version after two rows have been added, but none of this explains why you need to convert a table to a range to do any of this, where you have overlapping tables, or what you want your code to do.

  7. #7
    Forum Contributor
    Join Date
    02-01-2021
    Location
    Manchester
    MS-Off Ver
    365
    Posts
    216

    Re: Converting a table to a range in order to delete the name

    Taking my problem from the very start.
    There is another procedure, which I have not shown you which compared two sets of data and discovers whether the old list is missing some of the lines that are in the new list. If there are it puts them in "L3" and down.
    The point of procedure Sub NewEnter() is to take each value in Range("L3") and down and compare it with the equivalent values in the list "D4" current region.

    It does this by creating a table tblOld (the list with shortages) and a variant NewAr (the list of new codes)
    and looping round these to find a place in tblOld with a value above< NewAr value and a value below >NewAr, create a new row there and put in the value of NewAr. This works the first time the procedure is used. On subsequent runs the code stops at the line:-
    Please Login or Register  to view this content.
    with the error "A Table must not overlap another table"
    I had taken that to mean that the table name must have persisted. In that case you can hopefully see why I was searching for a way to remove the table name before recreating it.
    I hope this is more helpful. I wonder whether having put so much effort into this method of simply putting some values in the right places in a list, there is a different much more straight forward way
    Osprey

  8. #8
    Forum Contributor
    Join Date
    02-01-2021
    Location
    Manchester
    MS-Off Ver
    365
    Posts
    216

    Re: Converting a table to a range in order to delete the name

    I decided that as the table persists I would create the table by hand and remove the line above (set tblOld……….). In this case surely, I thought the rest of the code should work. But no there was another error message saying tblOld could not be found. Looking in the name manager there was a new table Table1 covering the range assigned to oldTable.
    It now looks as though I have to unlist Table 1 at the end of my procedure and the reinstate the Set tblOld line to recreate tblOld.
    I am relying on tblOld always being renamed as Table1, is it wise to do this?
    Osprey

+ 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. How to keep the table name after converting it to a range
    By cmorten82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-06-2018, 12:47 PM
  2. [SOLVED] Adding converting a range to a table into a macro
    By adrenom in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-31-2016, 05:00 PM
  3. Loose column widths when converting range to a table
    By ricmon in forum Excel General
    Replies: 0
    Last Post: 03-17-2016, 05:27 PM
  4. [SOLVED] VBA -How to keep existing range column headers when converting to table
    By Quinn.Farley in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2016, 05:30 PM
  5. [SOLVED] Formulas are not copying after converting a Table to a Range
    By johnw993 in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 02-22-2013, 12:39 AM
  6. [SOLVED] Converting Table to Range, Then Back to Table
    By Gard5096 in forum Excel General
    Replies: 1
    Last Post: 01-23-2013, 06:03 PM
  7. Pivot Table date range out of order
    By GeoGreco in forum Excel General
    Replies: 4
    Last Post: 03-07-2007, 06:58 PM

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