How to fix Expression.Error: a cyclic reference was encountered during evaluation

Viewed 1635

In Excel VBA I've made an input box to create a new sheet, name it and create a table on said sheet. When I try to add the table to the data model it returns this error after creating the query.

ActiveWorkbook.Queries.Add Name:=strName, Formula:= _
        "let" & Chr(13) & "" & Chr(10) & "    Source = Excel.CurrentWorkbook(){[Name=" & strName & "]}[Content]," & Chr(13) & "" & Chr(10) & "    #""Changed Type"" = Table.TransformColumnTypes(Source,{{""Date"", type any}, {""Time"", type any}, {""Call"", type any}, {""Greet"", type any}, {""Listen"", type any}, {""Engage"", type any}, {""Act"", type any}, {""Deliver"", type any}, {""Invite Back"", type any}, {""Total Score"", Int64.T" & _
        "ype}, {""Notes"", type any}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & "    #""Changed Type"""
    CurrentWorkbook.Connections.Add2 strName, _
    "Connection to the " & strName & "query in the workbook.", _
    "OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=" & strName & ";Extended Properties="_
  , "" & strName & "", 6, True, False

Where strName = InputBox("Enter Name")

Can anyone help me find/fix the cyclic reference?

0 Answers
Related