kajhvlksjdnf
09-06-2008, 11:01 PM
Greetings,
I've been trying to figure out why a certain piece of code crashes when I change the range past column Z. Any suggestions would be greatly appreciated.
----------------------------
Const FirstColumn As String = "AE"
totalCounter = 0
' For some reason a 400 error occurs when going above a range past Z
For Each cell In Range("B2:Z2") ' This works
' For Each cell In Range("B2:AC2") ' <--- THIS BREAKS and gives 400 ERROR
currentCell = cell.Address
activeColumn = Replace(Left(currentCell, 2), "$", "")
activeRow = Replace(Right(currentCell, 2), "$", "")
If cell.Value = 1 And Range(activeColumn & activeRow).Offset(0, -1) <> 1 Then
Range(FirstColumn & activeRow).Offset(0, totalCounter).Value = Range(activeColumn & 1).Value
' Make START time Bold
Range(FirstColumn & activeRow).Offset(0, totalCounter).Font.Bold = True
totalCounter = totalCounter + 1
ElseIf cell.Value = 1 And Range(activeColumn & activeRow).Offset(0, 1) <> 1 Then
Range(FirstColumn & activeRow).Offset(0, totalCounter).Value = Range(activeColumn & 1).Offset(0, 1).Value
totalCounter = totalCounter + 1
End If
Next
I've been trying to figure out why a certain piece of code crashes when I change the range past column Z. Any suggestions would be greatly appreciated.
----------------------------
Const FirstColumn As String = "AE"
totalCounter = 0
' For some reason a 400 error occurs when going above a range past Z
For Each cell In Range("B2:Z2") ' This works
' For Each cell In Range("B2:AC2") ' <--- THIS BREAKS and gives 400 ERROR
currentCell = cell.Address
activeColumn = Replace(Left(currentCell, 2), "$", "")
activeRow = Replace(Right(currentCell, 2), "$", "")
If cell.Value = 1 And Range(activeColumn & activeRow).Offset(0, -1) <> 1 Then
Range(FirstColumn & activeRow).Offset(0, totalCounter).Value = Range(activeColumn & 1).Value
' Make START time Bold
Range(FirstColumn & activeRow).Offset(0, totalCounter).Font.Bold = True
totalCounter = totalCounter + 1
ElseIf cell.Value = 1 And Range(activeColumn & activeRow).Offset(0, 1) <> 1 Then
Range(FirstColumn & activeRow).Offset(0, totalCounter).Value = Range(activeColumn & 1).Offset(0, 1).Value
totalCounter = totalCounter + 1
End If
Next