mailman
08-08-2008, 09:16 AM
Hi all. Can someone point out to me why this isn't working?
I'm running out of Excel 2003
counter = 0
For Each c In ActiveCell.CurrentRegion.Cells
If (c.Column > 2) Then GoTo Skip
If (c.value = "") And (c.Column = "2") And (Len(c.Offset(0, -1).value) > 0) Then
c.value = userName
Debug.Print c.Column & " Adjacent value:" & Len(c.Offset(0, -1).value)
Else
If (c.Column = 2) And Len(c.value) > 0 Then
userName = c.value
End If
End If
Skip:
counter = counter + 1
Next
The loop works great up until I try to add the third condition in the second If statement (checking the length of the adjacent cell).
It prints out ok in my Debug.Print statement, so I'm confused as to why this is occurring. :wot
I've left out my variable declarations for the sake of brevity...
I'm running out of Excel 2003
counter = 0
For Each c In ActiveCell.CurrentRegion.Cells
If (c.Column > 2) Then GoTo Skip
If (c.value = "") And (c.Column = "2") And (Len(c.Offset(0, -1).value) > 0) Then
c.value = userName
Debug.Print c.Column & " Adjacent value:" & Len(c.Offset(0, -1).value)
Else
If (c.Column = 2) And Len(c.value) > 0 Then
userName = c.value
End If
End If
Skip:
counter = counter + 1
Next
The loop works great up until I try to add the third condition in the second If statement (checking the length of the adjacent cell).
It prints out ok in my Debug.Print statement, so I'm confused as to why this is occurring. :wot
I've left out my variable declarations for the sake of brevity...