VBA Error 6: Overflow

Coyotyto

New Member
Joined
Feb 4, 2016
Messages
5
I have the code:

Sub ThresholdFormatting()
ThisWorkbook.Worksheets("Calculations").Activate
Dim i As Integer, m As Integer
For m = 3 To 28
For i = 6 To 10
If Cells(i, m).Value / Worksheets(1).Cells(i, m).Value > Cells(8, 39).Value Then
Cells(i, m).Font.Color = -16776961
Cells(i, m).TintAndShade = 0
Cells(i, m).Interior.Pattern = xlSolid
Cells(i, m).PatternColorIndex = xlAutomatic
Cells(i, m).ThemeColor = xlThemeColorAccent2
Cells(i, m).TintAndShade = 0.599993896298105
Cells(i, m).PatternTintAndShade = 0
End If
Next i
Next m
End Sub

Every time I run this Code the Error 6: Overflow comes up highlighting the start of the If statement. I have run this code without the contents of the If statement and still get the same error. My issue is that I am trying to manually conditional format based on the set criteria above. The if statement formula should check to see if the cell i am referencing divided by a cell in another worksheet is less than the cell 8, 39 which is a variable Threshold.

Thanks,
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
This works

Code:
Sub ThresholdFormatting()
ThisWorkbook.Worksheets("Calculations").Activate
Dim i As Integer
Dim m As Integer
For m = 3 To 28
For i = 6 To 10
n = Cells(i, m)
o = Worksheets(1).Cells(i, m)
If n > o Then
Cells(i, m).Font.Color = -16776961
Cells(i, m).TintAndShade = 0
Cells(i, m).Interior.Pattern = xlSolid
Cells(i, m).PatternColorIndex = xlAutomatic
Cells(i, m).ThemeColor = xlThemeColorAccent2
Cells(i, m).TintAndShade = 0.599993896298105
Cells(i, m).PatternTintAndShade = 0
End If
Next i
Next m
End Sub

though I can't see what's wrong orignally
 
Last edited:
Upvote 0
That's weird I replaced my change with your original line retyping

Code:
If Cells(i, m).Value > Worksheets(1).Cells(i, m).Value Then

and it's working!!??
 
Last edited:
Upvote 0
What I want it to check in the If statement is if the the cell in this worksheet divided by the cell in another worksheet is less than a certain cell that will have a set value then to change the text and fill of the cell. I tried the code but I need something like this:

Code:
[COLOR=#333333][FONT=arial black]If Cells(i, m).Value / Worksheets(1).Cells(i, m).Value > Cells(8, 39).Value Then[/FONT][/COLOR]

Cells(8, 39) will not change. My main issue has always been that the worksheet will alwasy be different so I am unable to set it to a particular sheet. it will just always be sheet 1.
 
Upvote 0
Delete the line with the condition and retype it, it worked for me, maybe's there's some odd characters on the line.
 
Upvote 0

Forum statistics

Threads
1,217,065
Messages
6,134,394
Members
449,870
Latest member
yuppies466

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top