PDA

View Full Version : Need help deciphering code

clhare
01-14-2009, 05:45 AM
I inherited an Excel file and it's macros. Before I make any updates, I'm trying to figure out exactly what the macros are currently doing. Can someone help me understand what is happening in the following section of code? It looks like the macro is taking a look at the values in columns 9 and 10 (which are either dates or nothing), so why does it say if "-"?

If (col = 11) Then
If OutArray(row, col - 2) = "-" Or OutArray(row, col - 1) = "-" Then
OutArray(row, col) = OutArray(row, col - 2) + 30
ElseIf (Int(DateDiff("d", OutArray(row, col - 2), OutArray(row, col - 1))) > 31) Then
OutArray(row, col) = OutArray(row, col - 1) + 2
Else
OutArray(row, col) = OutArray(row, col - 2) + 30
End If
End If

Thanks!

xld
01-14-2009, 06:56 AM
It is looking at an array not at the worksheet, so you need to look at how that array gets populated. I think it uses row and col variables just to think of that array in similar terms as a range.

clhare
01-14-2009, 07:24 AM
Ok, I understand that part... but why does it use "-" in the If statement. What does "-" mean? There are not dashes in the cells.

KevinTHFC
01-14-2009, 09:22 AM
But the code is looking at the contents an array not the contents of a cell on the worksheet.

xld
01-14-2009, 09:28 AM
Ok, I understand that part... but why does it use "-" in the If statement. What does "-" mean? There are not dashes in the cells.