Find tables with names with specific suffix in VBA

VBA code below finds tables which names end with specific sufix, e.g. tables with names ending with 'tab'.

Note that you can also do it with query.

Code

Public Sub find_tables_with_tab_suffix()
  Dim t As TableDef
  For Each t In CurrentDb().TableDefs
     If Right(t.Name, 3) = "tab" Then Debug.Print (t.Name)
  Next t
End Sub

Rows

  • One row represents a table
  • Scope of rows: all found tables

Sample results

Immediate Window shows names of all tables that ends with "tab"

sample results