我有下面的代码,我也需要这份工作。它检查D列以查看该值是否大于200,如果是,则在sheet2中查看vlookup以获取相应的值。但是,由于循环,我的方法需要很长时间才能加载。任何人都可以帮助我更快地制作代码或者采用不同的方法吗?感谢
Private Sub CommandButton1_Click()
Dim vlookup As Variant
Dim lastRow1 As Long, lastRow2 As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Dim i As Long
Set ws1 = Sheets("Sheet1")
lastRow1 = ws1.Cells(ws1.Rows.Count, "A").End(xlUp).Row
Set ws2 = Sheets("Sheet2")
lastRow2 = ws2.Cells(ws2.Rows.Count, "A").End(xlUp).Row
For i = 4 To lastRow1
If Cells(i, "D") > 200 Then
With ws1.Range("g4:g" & lastRow1)
.Formula = "=iferror(vlookup(a4, " & ws2.Range("a2:b" & lastRow2).Address(1, 1, external:=True) & ", 2, false), text(,))"
.value = .value
End With
Else
Cells(i, "g") = "Not found"
End If
Next i
End Sub
答案 0 :(得分:1)
将公式放入g4并将其复制
<div *ngIf="newComment && newComment.indexOf(product._id) > -1">