I have the code below, written by someone else and face an issue we have not seen before.
ReDim b(1 To UBound(a) * UBound(a, 2), 1 To 5)
For i = 2 To UBound(a, 1)
ant = a(i, 2)
ini = 0.01
For j = 2 To UBound(a, 2)
If ant <> a(i, j) Then
If ant <> "POA" Then
k = k + 1
b(k, 1) = a(i, 1)
b(k, 3) = ini
b(k, 4) = a(1, j - 1)
b(k, 5) = ant
End If
ini = a(1, j - 1) + 0.01
End If
ant = a(i, j)
Next j
Next i
The issue occurs when writing b(k 3) = ini to the array after the For statement has looped a number of times and the value of ini is incremented adding the + 0.01
There are ocassions where ini had a whole number value, which is then increased by 0.01 and becomes 11.01 or 12.01.
My issue is that while during the building of the array, the ini value shows correctly, when written to a worksheet, 11.01 and 12.01 are converted to a date format.
Can I prevent this from happening?
ReDim b(1 To UBound(a) * UBound(a, 2), 1 To 5)
For i = 2 To UBound(a, 1)
ant = a(i, 2)
ini = 0.01
For j = 2 To UBound(a, 2)
If ant <> a(i, j) Then
If ant <> "POA" Then
k = k + 1
b(k, 1) = a(i, 1)
b(k, 3) = ini
b(k, 4) = a(1, j - 1)
b(k, 5) = ant
End If
ini = a(1, j - 1) + 0.01
End If
ant = a(i, j)
Next j
Next i
The issue occurs when writing b(k 3) = ini to the array after the For statement has looped a number of times and the value of ini is incremented adding the + 0.01
There are ocassions where ini had a whole number value, which is then increased by 0.01 and becomes 11.01 or 12.01.
My issue is that while during the building of the array, the ini value shows correctly, when written to a worksheet, 11.01 and 12.01 are converted to a date format.
Can I prevent this from happening?