Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
When I put the following code into my first sheet, it runs fine but
when I put the same code into a second sheet, I get a runtime overflow error as noted in the code below. The only change in the code is that on the first sheet, it is set to run on Worksheet_Change and on the second sheet, it is set to run on Worksheet_Activate. I'm not sure why I'm getting the error. I have 12 sheets in my workbook that the code needs to go in to and I don't know how to loop the code for all 12 sheets so I'm trying to put them in on each sheet. Thanks in advance for any help. Sub Colors() Dim iRow As Long Dim iCol As Long For iRow = range("F7").Row To range("R42").Row Step 7 For iCol = range("F7").Column To range("R42").Column Step 2 doRange Cells(iRow, iCol) Next iCol Next iRow End Sub Sub doRange(rngtopleft As range) Application.ScreenUpdating = False With rngtopleft.Resize(7, 2) If rngtopleft.Value < Date Then .Interior.Pattern = xlGray50 Else .Interior.Pattern = xlSolid End If 'End With 'TEST CODE 'If range("A1").Value = range("M2") Then 'Exit Sub 'Else 'With rngtopleft.Resize(7, 2) 'range("A1") = range("M2") If rngtopleft.Interior.ColorIndex = 15 And rngtopleft.Value = 1 Then If rngtopleft.Column = range("F5").Column Or _ rngtopleft.Column = range("R5").Column Then .Interior.ColorIndex = 37 Else .Interior.ColorIndex = 40 End If End If If rngtopleft.Value = "" Then .Interior.ColorIndex = 15 End If End With '================================================= ======== '****OVERFLOW ERROR HERE***** With rngtopleft.Resize(1, 2) If rngtopleft.Value = DateSerial(range("M2"), 1, 14) + TimeSerial(20, 0, 0) Or _ rngtopleft.Value = DateSerial(range("M2"), 1, 21) + TimeSerial(20, 0, 0) Then '================================================= ======== If rngtopleft.Value = DateSerial(range("M2"), 1, 14) + TimeSerial(20, 0, 0) Then .Interior.ColorIndex = 5 .Font.ColorIndex = 2 With rngtopleft .Offset(0, 1) = "Derrick" End With End If If rngtopleft.Value = DateSerial(range("M2"), 1, 21) + TimeSerial(20, 0, 0) Then .Interior.ColorIndex = 5 .Font.ColorIndex = 2 With rngtopleft .Offset(0, 1) = "Jonathan" End With End If Else If rngtopleft.Column = range("F5").Column Or _ rngtopleft.Column = range("R5").Column Then .Interior.ColorIndex = 37 With rngtopleft .Offset(0, 1) = "" End With Else .Interior.ColorIndex = 40 With rngtopleft .Offset(0, 1) = "" End With End If .Font.ColorIndex = 1 End If If rngtopleft = "" Then .Interior.ColorIndex = 15 End If End With 'End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Overflow error.. why? | Excel Discussion (Misc queries) | |||
Error Code 6: Overflow | Excel Programming | |||
Overflow Error | Excel Programming | |||
Help! Overflow Error 6 | Excel Programming | |||
overflow error | Excel Programming |