How to find worksheet that contains specific table

radek

New Member
Joined
Mar 28, 2011
Messages
6
Hello everyone. I am in need to loop through all worksheets in my workbook and find which worksheet contain specific table. I know the table name, for instance table1. I thought that my concept will work, but it does not. I tried to use function intersect. I was thinking that if worksheet.cells intersects with table1 range then I finished my search.

If not intersect (sheets("aa").cells, sheets("aa").listobjects(table1)) is not nothing then ..
I have 20 worksheets in my workbook, so each time I am checking worksheet (in the loop) where there is not table1, then I am receiving error: Subscript out of range. And it make sense, there is no table1 on sheet("aa"), but may there is on sheet("bb"). Is there a better way to loop through worksheets to find that one that contains specific table, or maybe entirely different approach is needed in such search? Please help. thanks R
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
How about:

VBA Code:
Sub locateTable()
  MsgBox Range("Table1").Parent.Name
End Sub

The message shows you the name of the sheet where Table1 is located
🙂
 
Upvote 0

Forum statistics

Threads
1,222,830
Messages
6,168,509
Members
452,194
Latest member
Lowie27

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top