vba - 如何在VBA Excel中将文本更改为数字

标签 vba excel types compiler-errors

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

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/

相关文章:

java - 如何设置推断类型列表 getter 和 setter?

python - 如何 json 序列化自定义可迭代对象?

excel - 模拟按键效果

excel - 当 Evaluate Match 找不到它的条件时显示错误

Excel 无法使用 openpyxl 识别日期

excel - 将 Excel 数字复制到剪贴板时的小数精度

php - textarea 的字段类型是什么?

vba - 从字符串 VBA 或函数的开头删除零

xml - 使用 VBA 删除 Excel 中的 XML 重复项

c# - 导出到 Excel .xlsx 文件