如果则该语句结果为假

时间:2019-04-30 17:47:00

标签: excel vba

我的if-then语句即使条件为true也会为false

我尝试将值转换为两倍

    dblCompare = CDbl(rng1.Offset(0, -12).Value2)
    If dblTotal = dblCompare Then
        'If the values match, then record the Unique IDs in Columns AI:AN
        Range(Cells(m, 35), Cells(m, 35 + k - 1)) = arr
    End If

dblCompare = 114954.48和dblTotal = 114954.48。但是,该语句结果为false,并且完全跳过了将数组粘贴到Range中的操作。有时,if-then语句的结果为true,而数组的内容将粘贴到该范围中,但有时并非如此。 VBA似乎有很多错误。我能想到的是,需要将dblCompare类型转换为Double。

我的声明:

Option Explicit
Sub Find_Recs()
    Dim i As Integer, j As Integer, k As Integer, m As Integer
    Dim strSearch As String
    Dim dblTotal As Double, dblCompare As Double
    Dim rng1 As Range, rng2 As Range
    Dim arr As Variant
'
'
'code here
'
'
End Sub

0 个答案:

没有答案