Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.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
将Excel 2010中创建的宏转换为Excel Mac 2011_Excel_Vba - Fatal编程技术网

将Excel 2010中创建的宏转换为Excel Mac 2011

将Excel 2010中创建的宏转换为Excel Mac 2011,excel,vba,Excel,Vba,下面的宏在Excel 2010中运行,但在Excel for Mac 2011中,.Web命令出现错误。是否有Windows版本和Mac版本的命令列表 宏从股票中下载财务数据,这些股票的符号列在H列中。感兴趣的数据仅在某些表中,而不是所有表中,因此命令“.webtables”。该数据被复制到电子表格的另一部分,数据被清除并继续,直到符号列表用尽为止 遇到的错误: 在下一行,宏停止,Excel关闭工作簿: .Name = "Yahoo analyst estimates" 将上述行更改为: .N

下面的宏在Excel 2010中运行,但在Excel for Mac 2011中,.Web命令出现错误。是否有Windows版本和Mac版本的命令列表

宏从股票中下载财务数据,这些股票的符号列在H列中。感兴趣的数据仅在某些表中,而不是所有表中,因此命令“.webtables”。该数据被复制到电子表格的另一部分,数据被清除并继续,直到符号列表用尽为止

遇到的错误:

在下一行,宏停止,Excel关闭工作簿:

.Name = "Yahoo analyst estimates"
将上述行更改为:

.Name = False
允许宏继续,但不解释任何“.web”命令

因此,我的关键问题是为Mac2011的Excel找到类似“.web”的命令列表

' Download_Yahoo_Metrics Macro
' Downloads Tables for Analyst Estimates, Analyst Opinion and Key Statistics
'
Dim ScrURL As String
    lr = ActiveSheet.Cells(Rows.Count, "H").End(xlUp).Row 'delimits the last row
    fr = ActiveSheet.Cells(1, "C") 'delimits the first row
    For r = fr To lr
    Range("B5:F53").ClearContents 'clear previous
    ScrURL = "URL;http://finance.yahoo.com/q/ae?s=" & ActiveSheet.Cells(r, "H")
'
    With ActiveSheet.QueryTables.Add(Connection:=ScrURL, Destination:=Range("B5"))
    .Name = "Yahoo analyst estimates"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = False
    .RefreshPeriod = 0
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = "8,11,14,17,20,23"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = True
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
  End With
    With ActiveSheet
      .Cells(r, "i") = .Range("C47")
      .Cells(r, "j") = .Range("D47")
      .Cells(r, "k") = .Range("F47")
      .Cells(r, "l") = .Range("C48")
      .Cells(r, "m") = .Range("C49")
      .Cells(r, "n") = .Range("D49")
      .Cells(r, "o") = .Range("F49")
    End With
  Next
    Range("A1").Select
  End Sub

问题必须是连接,而不是查询表的名称。 尝试删除连接,然后创建表。 这里有一个链接可以帮助您:

据我所知,没有任何地方能列出Mac和Windows VBA for Excel之间的所有差异,尤其是不同版本的差异。谢谢你的提示。我已经看到了这个链接。连接实际上可以工作(在Excel windows中),如果我将.Name=“Yahoo analyst estimates”更改为.Name=False,宏将继续运行,但在到达“.web”命令时会再次停止。这些行似乎需要用Excel for Mac的正确命令替换。您是否已尝试在Excel 2011中创建宏以使用QueryTables,因为它取决于版本。尝试对ListObject执行相同的代码,看看是否可以这样工作。我在我的计算机上用vba编写了一些代码,使其他的查询表不起作用,只有ListObject。我不确定ListObject命令是什么,但我制作了使用查询表的宏,它们起作用了。我就是搞不懂这个。感谢您的提示。ListObjet与QueryTables相同,但没有设计,您可以在制作表格后放置。到目前为止,ListObject与所有版本的Excel都兼容。