如果有一定的价值,我有这个数据来对收益率范围进行分组。我在下面编写代码,但是它仅返回值elseif,如果小于60%,则其他单元格为空。可以帮助告知以下代码有什么问题吗? 运行代码后,附上M列的数据范围和结果。哪个空单元格应该填充值,但不是。
Sub FillIF()
Dim w2 As Worksheet
Dim lastrow1 As Long
Dim lastN As Long
Application.ScreenUpdating = False
Set w2 = Sheets("DataCompile")
On Error Resume Next
lastrow1 = w2.Cells(Cells.Rows.Count, "A").End(xlUp).Row
lastN = Range("N" & lastrow1).End(xlUp).Row + 1
For Each cell In w2.Range("M" & lastN & ":M" & lastrow1)
If cell.Value > 0 And cell.Value <= 0.3 Then
cell.Offset(0, 1).Value = "=<30% Yield"
ElseIf cell.Value > 0.3 And cell.Value <= 0.6 Then
cell.Offset(0, 1).Value = "=<60% Yield"
Else
cell.Offset(0, 1).Value = "60%><=100% Yield"
End If
Next
On Error GoTo 0
Application.ScreenUpdating = True
End Sub