D
dsi
I have some very weird problems, i must be missing something easy but i
have been at it for some time...
the following code is where I can isolate the diffrent behaviours
I assume that uncommenting solution 1 should result in the same
behaviour as uncommenting Solution 2 (with more robustness) but
instead, Solution 1 results in Message section 1 not appearing, the
Msgtest appearing over and over (infinite loop) and Message3-5 not
appearing. If I use Solution 2 I get code that works and does exactly
what I need except it isn't scalable (ie only checks 4 times) and all
messages appear as expected.
<code>
For RowIndex = rowstart To rowend
Set c = Selection.Find()
'Message section 1:
Message = MsgBox(c.Value, vbInformation)
Message1 = MsgBox(Cells(c.Row, colPrimary).Value, vbInformation)
Message2 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
'Solution 1:
' Do Until (Cells(c.Row, colPrimary).Value = "P")
' Msgtest = MsgBox("testing", vbInformation)
' Set c = Cells(c.Row + 1, c.Column)
' Message3 = MsgBox(c.Value, vbInformation)
' Message4 = MsgBox(Cells(c.Row, colPrimary).Value,
vbInformation)
' Message5 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
' Loop
' Solution 2
' If (Cells(c.Row, colPrimary).Value <> "P") Then
' Set c = Cells(c.Row + 1, c.Column)
' Message3 = MsgBox(c.Value, vbInformation)
' Message4 = MsgBox(Cells(c.Row, colPrimary).Value,
vbInformation)
' Message5 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
' End If
' If (Cells(c.Row, colPrimary).Value <> "P") Then
' Set c = Cells(c.Row + 1, c.Column)
' Message3 = MsgBox(c.Value, vbInformation)
' Message4 = MsgBox(Cells(c.Row, colPrimary).Value,
vbInformation)
' Message5 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
' End If
' If (Cells(c.Row, colPrimary).Value <> "P") Then
' Set c = Cells(c.Row + 1, c.Column)
' Message3 = MsgBox(c.Value, vbInformation)
' Message4 = MsgBox(Cells(c.Row, colPrimary).Value,
vbInformation)
' Message5 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
' End If
' If (Cells(c.Row, colPrimary).Value <> "P") Then
' Set c = Cells(c.Row + 1, c.Column)
' Message3 = MsgBox(c.Value, vbInformation)
' Message4 = MsgBox(Cells(c.Row, colPrimary).Value,
vbInformation)
' Message5 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
' End If
Next RowIndex
</code>
have been at it for some time...
the following code is where I can isolate the diffrent behaviours
I assume that uncommenting solution 1 should result in the same
behaviour as uncommenting Solution 2 (with more robustness) but
instead, Solution 1 results in Message section 1 not appearing, the
Msgtest appearing over and over (infinite loop) and Message3-5 not
appearing. If I use Solution 2 I get code that works and does exactly
what I need except it isn't scalable (ie only checks 4 times) and all
messages appear as expected.
<code>
For RowIndex = rowstart To rowend
Set c = Selection.Find()
'Message section 1:
Message = MsgBox(c.Value, vbInformation)
Message1 = MsgBox(Cells(c.Row, colPrimary).Value, vbInformation)
Message2 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
'Solution 1:
' Do Until (Cells(c.Row, colPrimary).Value = "P")
' Msgtest = MsgBox("testing", vbInformation)
' Set c = Cells(c.Row + 1, c.Column)
' Message3 = MsgBox(c.Value, vbInformation)
' Message4 = MsgBox(Cells(c.Row, colPrimary).Value,
vbInformation)
' Message5 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
' Loop
' Solution 2
' If (Cells(c.Row, colPrimary).Value <> "P") Then
' Set c = Cells(c.Row + 1, c.Column)
' Message3 = MsgBox(c.Value, vbInformation)
' Message4 = MsgBox(Cells(c.Row, colPrimary).Value,
vbInformation)
' Message5 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
' End If
' If (Cells(c.Row, colPrimary).Value <> "P") Then
' Set c = Cells(c.Row + 1, c.Column)
' Message3 = MsgBox(c.Value, vbInformation)
' Message4 = MsgBox(Cells(c.Row, colPrimary).Value,
vbInformation)
' Message5 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
' End If
' If (Cells(c.Row, colPrimary).Value <> "P") Then
' Set c = Cells(c.Row + 1, c.Column)
' Message3 = MsgBox(c.Value, vbInformation)
' Message4 = MsgBox(Cells(c.Row, colPrimary).Value,
vbInformation)
' Message5 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
' End If
' If (Cells(c.Row, colPrimary).Value <> "P") Then
' Set c = Cells(c.Row + 1, c.Column)
' Message3 = MsgBox(c.Value, vbInformation)
' Message4 = MsgBox(Cells(c.Row, colPrimary).Value,
vbInformation)
' Message5 = MsgBox(Cells(c.Row, colPrimary).Value = "P",
vbInformation)
' End If
Next RowIndex
</code>