刚刚开始使用VBA,我基本上是要查看列中的项目是否为文本,然后将其复制到一行中的另一个工作表中。我停在IF语句的第一行,错误424 - Object Required。
看了几个问题和网站,似乎无法弄清楚我哪里出错了。
非常感谢
Sub Copier()
Dim i As Integer
Dim j As Integer
j = 1
For i = 1 To 100
If IsText.Sheets("Strategies").Cells(i, 6) = True Then
Sheets("Strategies").Select
Cells(i, 6).Select
Selection.Copy
Sheets("Stats").Select
Cells(2, j).Select
Sheets("Stats").Paste
j = j + 1
End If
Next i
End Sub
答案 0 :(得分:0)
IsText
是WorksheetFunction
类的一种方法。
您的语法错误,更正将是:
If WorksheetFunction.IsText(Sheets("Strategies").Cells(i, 6)) = True Then
答案 1 :(得分:0)
不应使用IsText()
调用.
方法,而应使用()
,如下所示:
For i = 1 To 100
s = Sheets("Strategies").Cells(i, 6).Value
If Application.WorksheetFunction.IsText(s)Then
Sheets("Strategies").Select
Cells(i, 6).Select
Selection.Copy
Sheets("Stats").Select
Cells(2, j).Select
Sheets("Stats").Paste
j = j + 1
End If
Next i
答案 2 :(得分:0)
使用Variant非常快。
Sub test()
Dim i As Integer
Dim j As Integer
Dim Wf As WorksheetFunction
Dim fromWs As Worksheet, ToWs As Worksheet
Dim vDB, vR()
Set fromWs = Sheets("Strategies")
Set ToWs = Sheets("Stats")
Set Wf = WorksheetFunction
vDB = fromWs.Range("f1").Resize(100)
For i = 1 To UBound(vDB, 1)
If Wf.IsText(vDB(i, 1)) Then
j = j + 1
ReDim Preserve vR(1 To j)
vR(j) = vDB(i, 1)
End If
Next i
If j > 0 Then
ToWs.Range("a2").Resize(1, j) = vR
End If
End Sub
答案 3 :(得分:0)
你可以按如下方式整理整个事情:
marker.addListener('click', function() {
var destinationLat = marker.getPosition().lat();
var destinationLng = marker.getPosition().lng();
console.log(lat);
console.log(lng);
console.log(destinationLng);
console.log(destinationLat);
var test = $.getJSON('https://maps.googleapis.com/maps/api/directions/json?origin='+lat+'',''+lng+'&destination='+destinationLat+'',''+destinationLng+'&key=AIzaSyAirYgs4Xnt9QabG9v56jsIcCNfNZazq65', function(data) {
console.log(test);
});
console.log(test);
});
}