我编写了以下代码,以复制到特定范围的工作表(2)的某些范围的工作表(1)值的单元格中,这些值在特定范围的工作表(3)内不匹配:
var datefrom = $('#dateFrom').val();
var dateto = $('#dateTo').val();
$.ajax({
type: "POST",
url: "/DashBoard/fetchDataDetails?flag="+flag+"&from=" + datefrom + "&" + "to=" + dateto,
contentType: "application/json; charset=utf-8",
success: function (data) {
debugger;
if (data.length > 0) {
debugger;
var abc = data;
$('#example').DataTable({
"paging": true,
"ordering": true,
"info": true,
"columns": [
{ "data": "system_reference_no" },
{ "data": "mt_type" },
{ "data": "system_refdate" },
{ "data": "system_refamount" },
{ "data": "TransType_Code" },
{ "data": "sender" },
{ "data": "receiver" },
{ "data": "receiver_account" },
{ "data": "sender_account" },
{ "data": "sender_bic" },
{ "data": "receiver_bic" },
{ "data": "sender_bank" },
{ "data": "receiver_bank" },
{ "data": "creation_date" },
]
});
}
// processingGif(false);
},
error: function (data) {
// processingGif(false);
}
});
如果 Sub sortdata()
Dim i As Integer
Dim n As Integer
Dim w2 As Worksheet
Dim w1 As Worksheet
Dim w3 As Worksheet
Dim SW As String
Dim qrycolvaly As Range
Dim qrycolvalt As Range
Dim r As Range
Dim canceled(1 To 5) As String
Dim performed(1 To 200) As String
Dim startcell As Range
Set w2 = ThisWorkbook.Worksheets(2)
Set w1 = ThisWorkbook.Worksheets(1)
Set w3 = ThisWorkbook.Worksheets(3)
Set startcell = w1.Range("B9")
Set r = w3.Range("C1").End(xlDown)
Set qrycolvaly = w3.Range("C1", r)
For i = 1 To 200
With w2
SW = .Cells(i + 1, 3).Value
If IsError(WorksheetFunction.Match(SW, qrycolvaly, 0)) = True Then
performed(i) = SW
End If
End With
startcell.Offset(i - 1, 0).Value = performed(i)
Next i
End Sub
(工作表2的特定值范围)与指定范围的工作表3的值不匹配,我的代码将停止在指令上:
SW
错误:
1004:应用程序定义或对象定义错误
我已经尝试了很多东西,特别是在变暗时更改变量类型,但我不能让它工作。
¿有谁能告诉我我做错了什么?
答案 0 :(得分:1)
使用List<..>
代替condition
,它是VBA等效功能,并且不会生成错误消息。
然后您使用两个VBA函数(使用List<...> GetDependencies(...)
{
bool condition = ConditionEvaluator.EvaluateCondition(...);
if (!condition)
{
...
return new List<...>();
}
...
List<...> dependencyTargets = new List<...>();
...
return dependencyTargets;
}
)而不是VBA和Excel函数。
Application.Match
返回Excel值WorksheetFunction.Match
,而IsError
返回WorksheetFunction.Match
识别的VBA错误值(错误2042)。