Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.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中的宏显示错误_Excel_Macros - Fatal编程技术网

excel中的宏显示错误

excel中的宏显示错误,excel,macros,Excel,Macros,运行时错误:13 类型不匹配您可能在模块访问其他工作表上的数据时遇到问题。尝试以下操作以指定要从中提取的确切图纸: Sub Month_Update() Dim dDate As Date dDate = Range("$C$1").Value Range("$E$1").Value = _ DateSerial(Year(dDate), _ Month(dDate) + 1, Day(dDate)) End Sub 在单元格C12中使用2016/5/2

运行时错误:13

类型不匹配

您可能在模块访问其他工作表上的数据时遇到问题。尝试以下操作以指定要从中提取的确切图纸:

Sub Month_Update()
    Dim dDate As Date
    dDate = Range("$C$1").Value
    Range("$E$1").Value = _
    DateSerial(Year(dDate), _
    Month(dDate) + 1, Day(dDate))
End Sub

在单元格C12中使用2016/5/2作为值,我只是尝试使用您发送的日期,一切正常。您如何在C1单元格“信息收集日期”“付款通知发布日期”“薪资发放日期”2016/5/2 2016/5/3 2016/5/5 2016/5/4 2016/5/6 2016/5/10子月更新()Dim dDate As Date dDate=范围($D$1”)。值范围($F$1”)。值=uuuu日期序列(年(dDate),uu月(dDate)+1天(dDate))End Sub仍然获取运行时错误13:类型不匹配我要做的是自动将日期更改为下个月。请帮助:)尝试使用我发布的新代码。并将“Sheet1”值替换为数据所在工作表的名称。
Sub Month_Update()
    Dim ws As Worksheet
    Set ws = Excel.Sheets("Sheet1") 'Replace This Sheet1 Value with the Name of the Sheet that the data is on
    Dim dDate As Date
    dDate = ws.Range("$D$1").Value
    ws.Range("$E$1").Value = _
    DateSerial(Year(dDate), _
    Month(dDate) + 1, Day(dDate))
End Sub