LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Overflow error - same code, different sheet

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Overflow error.. why? Fingerjob Excel Discussion (Misc queries) 4 November 13th 06 05:18 PM
Error Code 6: Overflow Shawn Excel Programming 6 July 23rd 05 04:45 AM
Overflow Error DG Excel Programming 3 April 15th 05 05:45 PM
Help! Overflow Error 6 Gauthier Excel Programming 6 September 24th 04 12:57 PM
overflow error ExcelMonkey[_5_] Excel Programming 6 January 22nd 04 02:34 AM


All times are GMT +1. The time now is 07:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"