Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default make a list of the listobjects on a worksheet

Hi,

I am sure this must be easy, but somehow I'm not "getting it" today.

How can I generate the names of the list objects on a worksheet?

This is close, except it gives me the count:
Sub test()
Dim i
Dim LObs
For i = 1 To Worksheets.Count
LObs = LObs + Worksheets(i).ListObjects.Count
Next i
MsgBox "There are " & LObs & " list objects in the workbook."
End Sub

I'd like to know the item names of the listobjects.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default make a list of the listobjects on a worksheet

This should get you started

Sub test()
Dim LObs As Long
Dim WS As Worksheet
Dim aWB As Workbook
Dim ListObj As ListObject

Set aWB = ActiveWorkbook
For Each WS In aWB.Worksheets
LObs = LObs + WS.ListObjects.Count
For Each ListObj In WS.ListObjects
Debug.Print WS.Name, ListObj.Name
Next ListObj
Next WS
MsgBox "There are " & LObs & " list objects in the workbook."
End Sub

--
HTH,
Barb Reinhardt



" wrote:

Hi,

I am sure this must be easy, but somehow I'm not "getting it" today.

How can I generate the names of the list objects on a worksheet?

This is close, except it gives me the count:
Sub test()
Dim i
Dim LObs
For i = 1 To Worksheets.Count
LObs = LObs + Worksheets(i).ListObjects.Count
Next i
MsgBox "There are " & LObs & " list objects in the workbook."
End Sub

I'd like to know the item names of the listobjects.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default make a list of the listobjects on a worksheet

Hi Barb,

Yes, thank you very much!

On my own I came up with something similar

Sub GetNames()
Dim obj as ListObject
For Each obj In ActiveSheet.ListObjects
MsgBox obj.Name
Next obj
End Sub

Life is good again.

-Jim

On Aug 27, 1:28 pm, Barb Reinhardt
wrote:
This should get you started

Sub test()
Dim LObs As Long
Dim WS AsWorksheet
Dim aWB As Workbook
Dim ListObj As ListObject

Set aWB = ActiveWorkbook
For Each WS In aWB.Worksheets
LObs = LObs + WS.ListObjects.Count
For Each ListObj In WS.ListObjects
Debug.Print WS.Name, ListObj.Name
Next ListObj
Next WS
MsgBox "There are " & LObs & "listobjects in the workbook."
End Sub

--
HTH,
Barb Reinhardt

" wrote:
Hi,


I am sure this must be easy, but somehow I'm not "getting it" today.


How can I generate the names of thelistobjects on aworksheet?


This is close, except it gives me the count:
Sub test()
Dim i
Dim LObs
For i = 1 To Worksheets.Count
LObs = LObs + Worksheets(i).ListObjects.Count
Next i
MsgBox "There are " & LObs & "listobjects in the workbook."
End Sub


I'd like to know the item names of thelistobjects.


Thanks


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If ActiveSheet.ListObjects = True ... Not Working ryguy7272 Excel Programming 2 April 2nd 08 08:14 PM
How do I make appear one line of a list in a different worksheet? Edoardo Excel Discussion (Misc queries) 1 November 1st 06 06:17 PM
ListObjects.Add error doug Excel Programming 0 July 6th 06 03:41 PM
listobjects and querytables S. Parker Excel Programming 0 November 14th 05 09:08 AM


All times are GMT +1. The time now is 04:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"