Results 1 to 6 of 6

Convert all Tables to Range

Threaded View

  1. #1
    Registered User
    Join Date
    10-11-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Convert all Tables to Range

    Hi all,

    I've currently got some data linked in from a database in several different sheets. They seem to be held is some special Excel Tables which, if i right click anywhere in them it gives me the option of Table -> Convert to Range.

    I also currently have a macro that attempts to remove all formulas and data sources, which works. But it also doesn't allow what were the data tables to be filtered unless i convert them to a range. (macros and VBA are very new to me so it's probably really badly coded), below is what my macro is doing so far.

    Sub ClearFormulae()    
        'Refresh all connections and recalculate any formulas (incase calculations are turned off)
        ActiveWorkbook.RefreshAll
        Application.Calculate
        
        'Remove all external database connection (will also remove connections to other workbooks)
        For Each objConn In ActiveWorkbook.Connections
           objConn.Delete
        Next objConn
            
        'Save a collection of all sheets that were hidden for later, then make them visible
        'Needs to be done to ensure other sheets get the data they need before hidden sheets are deleted
        Dim sh As Worksheet, HidShts As New Collection
        For Each sh In ActiveWorkbook.Worksheets
            If Not sh.Visible Then
                HidShts.Add sh
                sh.Visible = xlSheetVisible
            End If
        Next sh
        
        'Loop through every active sheet Doing 'Select everything', 'PasteSpecial', 'ValuesOnly'
        Dim ws As Worksheet
        For Each ws In ActiveWorkbook.Worksheets
            With ws
                .Activate
                .Cells.Copy
                .Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                .Range("A1").Select
            End With
            Application.CutCopyMode = False
        Next
        
    '    # Deletes the sheets that were originally hidden
        For Each sh In HidShts
            sh.Delete
        Next sh
    End Sub
    I have done some searching but can't find a way to hunt down any excel "tables" and convert them to range in the above macro. Is this possibe?

    Thanks a lot for any help!!

    Mathew
    Last edited by mfrost; 10-11-2010 at 11:31 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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