Date 从日期VBA中减去时类型不匹配
以下操作将引发类型不匹配:Date 从日期VBA中减去时类型不匹配,date,types,reference,numbers,Date,Types,Reference,Numbers,以下操作将引发类型不匹配: ws.Cells(1, 2) = ws.Cells(1, 1) - 1 然而,它仍然发挥作用。我在不同的地方添加了.Value,它没有任何区别(正面或负面)。我一直在使用“on error resume next”,但它运行非常缓慢,经常崩溃(错误是excel没有足够的资源来完成此过程)。有什么建议吗 提前谢谢大家 Sub PSOPEN(wb As Workbook) 'On Error Resume Next 'Add date range to the wor
ws.Cells(1, 2) = ws.Cells(1, 1) - 1
然而,它仍然发挥作用。我在不同的地方添加了.Value,它没有任何区别(正面或负面)。我一直在使用“on error resume next”,但它运行非常缓慢,经常崩溃(错误是excel没有足够的资源来完成此过程)。有什么建议吗
提前谢谢大家
Sub PSOPEN(wb As Workbook)
'On Error Resume Next
'Add date range to the worksheets to allow import of correct values
Dim ws As Worksheet
With wb
For Each ws In wb.Worksheets
ws.Cells(1, 1) = ws.Name
ws.Cells(1, 1).NumberFormat = "m/d/yyyy"
ws.Cells(1, 2) = ws.Cells(1, 1).Value - 1
Dim file_date
file_date = Format(ws.Cells(1, 1), "dd.mm.yy")
Dim file_date1
file_date1 = Format(ws.Cells(1, 2), "dd.mm.yy")
If ws.Cells(1, 1) = ws1.Cells(1, 1) Then
ws.Activate
Cells.Select
Selection.Copy
Windows("Myfile " & file_date & ".xlsm").Activate
Sheets("Sheet1").Activate
Cells.Select
ActiveSheet.Paste
ws.Activate
End If
If ws.Cells(1, 1) = ws1.Cells(1, 1) + 1 Then
ws.Activate
Cells.Select
Selection.Copy
Windows("Myfile " & file_date1 & ".xlsm").Activate
Sheets("Sheet2").Activate
Cells.Select
ActiveSheet.Paste
ws.Activate
End If
Next ws
End With
End Sub
这有什么特别的语言吗?如果是,什么?嗨,斯科特。应该说,它在VBA中