def get_table(self, name):
        """
        Return a table, worksheet pair for the named table
        """
        if name is None:
            assert self.active_table, "Can't get table without name unless an active table is set"
            name = self.active_table.name

            if self.active_worksheet:
                table = self.active_worksheet.get_table(name)
                assert table is self.active_table, "Active table is not from the active sheet"
                return table, self.active_worksheet

            for ws in self.worksheets:
                try:
                    table = ws.get_table(name)
                    if table is self.active_table:
                        return table, ws
                except KeyError:
                    pass

            raise RuntimeError("Active table not found in any sheet")

        # if the tablename explicitly uses the sheetname find the right sheet
        if "!" in name:
            ws_name, table_name = map(lambda x: x.strip("'"), name.split("!", 1))
            for ws in self.worksheets:
                if ws.name == ws_name:
                    table = ws.get_table(table_name)
                    return table, ws
            raise KeyError(name)

        # otherwise look in the current table
        if self.active_worksheet:
            table = self.active_worksheet.get_table(name)
            return table, self.active_worksheet

        # or fallback to the first matching name in any table
        for ws in self.worksheets:
            try:
                table = ws.get_table(name)
                return table, ws
            except KeyError:
                pass

        raise KeyError(name)
Return a table, worksheet pair for the named table