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
Bookmarks