Making a Table with a unique name referring to the active worksheet

Good Morning,
Unlike named range, tables are unique to a range in a workbook and cannot be referred with the same name in each worksheet.
If I choose a range for a table and assign it a name, I cannot via name manager change the scope from workbook to every worksheet, or use the old trick of =!X1:X12 where the ! means that range is for each worksheet.
This means that if I have identically structured worksheet, I need to have tables made for each individual sheets. This is feasible with the number of sheets I have only about 12, but I was wondering whether there is another way of proceeding for other workbook where I would like to do the same?
The table in this case will be filled through VBA by data that is obtained from one calculated range from data copied from another source. The rows of the table are built up from that data but not identically for each worksheet as some results give null results in some experiments or real values in others. That is to say I would run the VBA code for each sheet independently so that all is done only in the active worksheet.
I wanted to keep one unique name in the VBA code as I organise a spreadsheet, then copy it for the number of experiments being run. Right now, the table built in the first sheet say Table1 remains for that sheet whilst the other sheets, a new table name is created. At least a table is created ! so how would I then make sure that with my code, the code refers to that (new) table in an active worksheet?
Here is my code
Sub Recup()
Dim sht As Worksheet
Dim tbl As ListObject
Dim table_object_row As ListRow

Set sht = Sheets(4)
Set tbl = sht.ListObjects("Table1")
last_row_with_data = sht.Range("Y65536").End(xlUp).Row
If last_row_with_data = sht.Range("Y13") Then
Set table_object_row = tbl.ListRows
Else: Set table_object_row = tbl.ListRows.Add
End If

sht.Range("Y" & last_row_with_data).Value = Range("AJ10")
sht.Range("Z" & last_row_with_data).Value = Range("AK10")
sht.Range("AA" & last_row_with_data).Value = Range("AL10")
sht.Range("AB" & last_row_with_data).Value = Range("AM10")
sht.Range("AC" & last_row_with_data).Value = Range("AN10")
sht.Range("AD" & last_row_with_data).Value = Range("AO10")
sht.Range("AE" & last_row_with_data).Value = Range("AP10")
sht.Range("AF" & last_row_with_data).Value = Range("AQ10")
sht.Range("AG" & last_row_with_data).Value = Range("AR10")

End Sub 

Open in new window


The table in the first sheet is called Table 1 so that the next one might be called Table2 etc.
The tab numbers have names referring to the individual experiment either by date or by individuals so that it is actually difficult to see which one is the next sheet unless the dates follow quite regularly which they do not.
How could I make a table in each sheet that is recognisable by one single macro (above)?
What line of code can make sure I choose the right region in the active worksheet?
There are NO other tables in that workbook except those duplicated tables. There might be an extra table added in an extra sheet added afterwards to compile all the results, but this table would only apply to that worksheet.

Named ranges seem more flexible than tables and probably would be the best choice here?
 I wrote the code from snippets of codes  and I would not know how to proceed to change the code for a table to code for a named range.


Thank you helping me out Table properties, and/or VBA workaround to the limitation of Tables, if indeed Tables can only refer to one unique specific range in a specific worksheet.
I have a long way to go with coding, so any help there would be a huge help in this case.

Cheers,
Danièle
Daniele QuestiauxResearch associateAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
If you want to refer to the last table added on a sheet (or the only one if there's just one) then change this

Set tbl = sht.ListObjects("Table1")

to

Set tbl = sht.ListObjects(sht.ListObjects.Count)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Martin LissOlder than dirtCommented:
And to avoid doing something on the extra sheet that I'll call "ExtraSheet")

Dim sht As Worksheet

For Each sht In Worksheets
    If sht.Name <> "ExtraSheet" Then
        ' Do normal code
    Else
        ' Do code, if any, for the extra sheet
    End If
Next

Open in new window

Daniele QuestiauxResearch associateAuthor Commented:
A thorough reply!

Exactly as requested, a code line to refer to the last table created in the worksheet without having to know its index number together with a line of code to ensure that any worksheet where the code should not apply to are definitely left out.
A thorough answer.

Thanks!
Danièle
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.