Randall00
Board Regular
- Joined
- Jan 31, 2008
- Messages
- 54
Hi there!
This is about the ever-unfolding mysteries surrounding Tables from Office 2007 in VBA.
The lovely piece of code below does a fine job of removing the Table style from Table1 and converting it to a normal range:
It's the ListObjects("Table1") bit that I'm wondering about. Every piece of code related to tables that I can find seems to refer to them in this way, but the question is:
Is there a way to refer to the active table?
i.e.
I imagine this comes back to declaring variables in way that I don't quite understand--a point in the right direction would be appreciated, thanks!
This is about the ever-unfolding mysteries surrounding Tables from Office 2007 in VBA.
The lovely piece of code below does a fine job of removing the Table style from Table1 and converting it to a normal range:
Code:
Sub RemoveTableStyle()
Dim oSh As Worksheet
Set oSh = ActiveSheet
'remove table or list style
oSh.ListObjects("Table1").Unlist
End Sub
It's the ListObjects("Table1") bit that I'm wondering about. Every piece of code related to tables that I can find seems to refer to them in this way, but the question is:
Is there a way to refer to the active table?
i.e.
Rich (BB code):
Sub RemoveTableStyle()
Dim oSh As Worksheet
Set oSh = ActiveSheet
'remove table or list style
ActiveSheet.ActiveTable??.Unlist
End Sub
I imagine this comes back to declaring variables in way that I don't quite understand--a point in the right direction would be appreciated, thanks!