Application Match
对于一列有效,但是对于两列却给我错误
With Sht
LastRow = .Cells(.Rows.Count, "J").End(xlUp).Row
For i = LastRow To 2 Step -1
DupRow = Application.Match(Cells(i, 9).Value, Range(Cells(1, 9), Cells(i - 1, 9)), 0)
DoEvents
If Not IsError(DupRow) Then
Cells(i, 8).Value = Cells(i, 8).Value + Cells(DupRow, 8).Value
Cells(i, 9).Value = Cells(i, 9).Value + Cells(DupRow, 9).Value
Rows(DupRow).Delete
End If
Next i
End With
2列错误运行时1004
DupRow = Application.Match(Cells(i, 4).Value & Cells(i, 5).Value, Range(Cells(1, 4) & Cells(1, 5), Cells(i - 1, 4) & Cells(i - 1, 5)), 0)
正确的做法是什么?
答案 0 :(得分:0)
我认为最好使用字典,字典具有内置的密钥管理方法,因此可以用来获取唯一值:
def criminals(request):
if request.method=="POST":
cn = request.POST['crname']
ccrime = request.POST['crime']
cage = request.POST['age']
cheight=request.POST['height']
cbody = request.POST['bodymark']
crgen = request.POST['gender']
s= Criminals()
s.mname=cn
s.mcrime=ccrime
s.mage=cage
s.image = request.FILES['photo']
s.mheight=cheight
s.mbody=cbody
s.mgender=crgen
s.save()
messages.success(request,"Criminal Added Successfully.")
return render(request,'criminal.html')
else:
return render(request,'criminal.html')