Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 对powerquery的单元格引用_Vba_Excel_Powerquery - Fatal编程技术网

Vba 对powerquery的单元格引用

Vba 对powerquery的单元格引用,vba,excel,powerquery,Vba,Excel,Powerquery,我有一个电源查询,其中我试图从Shift Sched sheet中获取单元格Z13中的链接。Z13中的链接将为我获取包含数据的excel文件。单元名称定义为REFCELL 这是我从record macro那里得到的数据。 子powerquery ' 'powerquery宏 " " 范围13.选择 ActiveWorkbook.Queries.Add名称:=计划,公式:=_ let&Chr13&&Chr10&Source=Excel.WorkbookWeb.Contents Schedules/

我有一个电源查询,其中我试图从Shift Sched sheet中获取单元格Z13中的链接。Z13中的链接将为我获取包含数据的excel文件。单元名称定义为REFCELL

这是我从record macro那里得到的数据。 子powerquery ' 'powerquery宏 "

" 范围13.选择 ActiveWorkbook.Queries.Add名称:=计划,公式:=_ let&Chr13&&Chr10&Source=Excel.WorkbookWeb.Contents Schedules/Shift Schedules和Emp Details w.e.f Jun 032018-HYD.xlsx,null,true,&Chr13&&Chr10&Schedules\u Sheet=Source{[Item=Schedules,Kind=Sheet]}[Data],&Chr13&&Chr10&Changed Type=Table.TransformColumnTypesSchedules\u Sheet,{{Column1 text},{Column2,type&_ text},{Column3,type text},{Column4,type any},{Column5,type text},{Column6,type text},{Column7,type any},{Column8,type any},{Column9,type text},{Column10,type text},{Column11,type text},{Column12,type text},{Column13,type text},{Column14,type text},{Column15,type text},{Column16,type&_ text},{Column17,type text},{Column18,type text},{Column19,type any},{Column20,type text},{Column21,type text},{Column22,type text},{Column23,type any},{Column24,type any},{Column25,type any},{Column26,type any Column27,type any},{Column28,type any},{Column29,type any Column30,ty&_ pe any},{Column31,type text},{Column32,type any},{Column33,type text},{Column34,type text},{Column36,type any},{Column37,type text},{Column38,type text},{Column39,type any},{Column40,type any},{Column41,type any},{Column42,type text},{Column43,type any}&Chr13&&Chr10&in&Chr13&&Chr10&C&_ 悬挂式 Sheets.Add After:=ActiveSheet 使用ActiveSheet.ListObjects.AddSourceType:=0,Source:=_ OLEDB;提供程序=Microsoft.Mashup.OLEDB.1;数据源=$Workbook$;位置=计划;扩展属性=_ ,目标:=范围$A$1.QueryTable .CommandType=xlCmdSql .CommandText=ArraySELECT*自[附表] .rowNumber=False .FillAdjacentFormulas=False .PreserveFormatting=True .refreshinfoleopen=False .BackgroundQuery=True .RefreshStyle=xlInsertDeleteCells .SavePassword=False .SaveData=True .AdjustColumnWidth=True .RefreshPeriod=0 .PreserveColumnInfo=False .ListObject.DisplayName=Schedules\u 2 .Refresh BackgroundQuery:=False 以 Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False 端接头


**这对我不起作用,因为链接会根据日期(例如2018年6月3日)不断变化。链接必须从班次计划表中的单元格z13中获取,并加载到新表中。

这几乎都与将引号放在正确的位置以正确编译查询字符串有关。请尝试以下操作:

ActiveWorkbook.Queries.Add _
    Name:="Schedules", _
    Formula:="let" & vbCr & _
            vbTab & "MyURL = Excel.CurrentWorkbook(){[Name=""REFCELL""]}[Content][Column1]{0}," & vbCr & _
            vbTab & "Source = Web.Page(Web.Contents(MyURL))" & vbCr & _
            "in Source"

Z13是否包含要加载的文件的文件路径?什么不起作用?是否有错误?是什么?是的,它有excel工作表时间表/轮班时间表和Emp详细信息的路径w.e.f Jun 03,2018-HYD.xlsx这会随着日期不断变化。我想要一个VBA代码,它应该在其中通过z13中的e web链接。我得到以下查询并得到一个错误。**************表达式。错误:键与表中的任何行都不匹配。详细信息:键=记录表=表************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************[Column1]{0},Source=Web.PageWeb.ContentsMyURL,Schedules\u Sheet=Source{[Item=Schedules,Kind=Sheet]}[Data],Changed Type=Table.TransformColumnTypesSchedules\u Sheet,{{Column1,Type text},{Column2,Type text},在Changed Type中,您试图查询的URL是什么?