Is there a way to convert a string to an integer using VBA? I have written some nested If's inside of a loop in order to find the next available extension to use while creating a work breakdown structure.....(not important) The code follows:
For n = 6 To r
If Cells(n, 4) <> "--" Then
projectNum2 = Left(Cells(n, 4).Value, 1)
taskExtension = Right(Cells(n, 4).Value, 1)
If projectNum2 = projectNum Then <-------------------------
comparison in question
If taskExtension > newTaskNum Then
newTaskNum = taskExtension
Cells(n, 11) = newTaskNum
End If
End If
End If
Next n
This is how I get projectNum:
itemIndex = ChooseProject.ListIndex + 6
projectNum = Cells(itemIndex, 2).Value
The problem is that the comparison never returns true even though I know that the two numbers are equal. I displayed the values to be sure that they really do match. I tried CInt(projectNum2) and it returns a "type mismatch" error. Type casting, or otherwise, I would really appreciate any help. Thanks.
Start Free Trial