我想将单元格内容转换为数字值,以便可以比较值。

If Cells(r, c) >= Cells(157, c) Then Cells(i, c) = Cells(r, 3)

我需要如何做的帮助
Sub comp_above_median()

For c = 6 To 19
 i = 160

    For r = 2 To 155
        If Cells(r, c) >= Cells(157, c) Then Cells(i, c) = Cells(r, 3)
        If Cells(r, c) >= Cells(157, c) Then i = i + 1

    Next r

Next c

End Sub

我收到运行时错误13:输入不匹配的行
If Cells(r, c) >= Cells(157, c) Then Cells(i, c) = Cells(r, 3)

最佳答案

尝试这个

    Sub comp_above_median()
    For c = 6 To 19
     i = 160
        For r = 2 To 155
            If Val(Cells(r, c)) >= Val(Cells(157, c)) Then
            Cells(i, c) = Cells(r, 3)
            i = i + 1
            End If
        Next r
    Next c
    End Sub

关于vba - 如何在VBA Excel中将文本更改为数字,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44669238/

10-12 23:49