I’m having trouble with a for loop in my program. Right now I have two arrays that are populated with arbitrary numbers. These two arrays are the same size. Basically I want the user to specify what sort of operation they want done on the arrays and then I’ll perform them (given that the arrays are the same dimensions). Below is the code for me trying to populate an answer array with the difference between the original two arrays:
If (LCase(diffOrPercent = "difference")) Then
For iRow = 1 To totalRow
For iCol = 1 To totalCol
answerArray(iRow, iCol) = s2Array(iRow, iCol) - s3Array(iRow, iCol)
Next iCol
Next iRow
End If
The problem that I’m having is that the answerArray is entirely blank when I try to print it out. Does anyone know what’s going on?
Note: The same error occurs if the for loops go from 0 to end – 1, when i put the following:
answerArray(iRow, iCol) = s2Array(iRow, iCol).Value2 - s3Array(iRow, iCol).Value2
As well as when I put Value instead of Value2.
Thank you,
Jesse Smothermon
I figured it out, the if statement was written incorrectly so the operation portion of the code wasn’t even being hit. I screwed up the parenthesis on LCase, so the correction is below
This makes it so that the variable diffOrPercent will be all lowercase instead of….. well I don’t think anything happens when my original if statement is implemented which makes sense because nothing within the if statement gets hit. Sorry that I completely wasted everyone’s time on this one, but I really appreciate all of the quick responses