K
kaon
Hi all,
I am wondering if this is a bug for excel.
Here is the (simplified and ugly) code: (Problem details right afte
the code)
Sub test()
Dim i As Integer, j As Integer, k As Integer, h As Integer, l A
Integer
Dim poNo As String
k = 5
For h = 1 To Worksheets("Raw Data").UsedRange.Columns.Count
If Cells(1, h).Value = "Po No" Then
Exit For
End If
Next h
For j = 1 To Worksheets("Raw Data").UsedRange.Columns.Count
If Cells(1, j).Value = "Je Period" Then
Exit For
End If
Next j
End Sub
I have 2 sheets (Settings, Raw Data)
When I add the following line just before "End Sub" and run:
Msgbox _
Worksheets("Settings").Cells(66,h).Value = _
Worksheets("Raw Data").Cells(149, j).Value
Msgbox with "False" is appeared.
Later on, I changed the line to:
Msgbox _
Worksheets("Settings").Cells(66,h).Value & " " &
Worksheets("Raw Data").Cells(149, j).Value
Msgbox with "123456 123456" is appeared.
And further I changed the line to :
Msgbox _
Len(Worksheets("Settings").Cells(66,h).Value) & " " &
Len(Worksheets("Raw Data").Cells(149, j).Value)
And
Msgbox Instr(1, _
Worksheets("Settings").Cells(66,h).Value, _
Worksheets("Raw Data").Cells(149, j).Value)
Result of former one: 6 6
Result of latter one: 1
So I am wondering why direct cell comparsion will give "false".
Thanks
I am wondering if this is a bug for excel.
Here is the (simplified and ugly) code: (Problem details right afte
the code)
Sub test()
Dim i As Integer, j As Integer, k As Integer, h As Integer, l A
Integer
Dim poNo As String
k = 5
For h = 1 To Worksheets("Raw Data").UsedRange.Columns.Count
If Cells(1, h).Value = "Po No" Then
Exit For
End If
Next h
For j = 1 To Worksheets("Raw Data").UsedRange.Columns.Count
If Cells(1, j).Value = "Je Period" Then
Exit For
End If
Next j
End Sub
I have 2 sheets (Settings, Raw Data)
When I add the following line just before "End Sub" and run:
Msgbox _
Worksheets("Settings").Cells(66,h).Value = _
Worksheets("Raw Data").Cells(149, j).Value
Msgbox with "False" is appeared.
Later on, I changed the line to:
Msgbox _
Worksheets("Settings").Cells(66,h).Value & " " &
Worksheets("Raw Data").Cells(149, j).Value
Msgbox with "123456 123456" is appeared.
And further I changed the line to :
Msgbox _
Len(Worksheets("Settings").Cells(66,h).Value) & " " &
Len(Worksheets("Raw Data").Cells(149, j).Value)
And
Msgbox Instr(1, _
Worksheets("Settings").Cells(66,h).Value, _
Worksheets("Raw Data").Cells(149, j).Value)
Result of former one: 6 6
Result of latter one: 1
So I am wondering why direct cell comparsion will give "false".
Thanks