The below shortened code section fails to work out. When I attempt to define the range the name "tablename" refers to, I obviously commit some kind of mistake in this line of the code:
Names.Add Name:=FullRangeName, RefersTo:=wsNum.Range(Cells(3, 1), Cells(lentgth, width))
The cells of the reference range are located in different sheets. Can that be the root cause?
The code stops running at the above line. (The subsequent message box is substituting further code content.)
The script looks like:
Sub ggfgfd()
    Dim wsCtrl As Worksheet
    Dim wsNum As Worksheet
    Set wsCtrl = Workbooks("trez.xlsm").Sheets("ltto")
    Set wsNum = Workbooks("trez.xlsm").Sheets("figures")
    If wsCtrl Is Nothing Then
        MsgBox " blabla"
        Exit Sub
    End If
    wsNum.Activate
    wsCtrl.Activate
    Dim width As Byte
    width = wsCtrl.Cells(1, 3).Value
    Dim length As Byte
    length = wsCtrl.Cells(2, 3).Value
    Dim FullRangeName As String
    FullRangeName = "tablename"
    Names.Add Name:=FullRangeName, RefersTo:=wsNum.Range(Cells(3, 1), Cells(lentgth, width))
    MsgBox FullRangeName.Value
End Sub
I've tried to replace the cell references width, length with fix numbers, but that doesn't help either. Actually even this code has already worked out until I separated the code into two Excel sheets, therefore my guess was, that the source definition in RefersTo:= ....  has an incorrect syntax.
Thanks for your efforts.
 
    