overflow

synergy16

Active Member
Joined
Mar 17, 2016
Messages
422
Office Version
  1. 365
Platform
  1. Windows
can anybody tell me when the code (written in red) would cause a run time error 6....overflow? its not that big of a spreadsheet.




Code:
'***************************THIS SUB WILL POPULATE THE CURRENT PART NUMBERS AT A SPECIFIC VENDOR********************************Private Sub vendorLB_Click()
    Dim prtNumsV() As Variant
    Dim cntrV, t, y, venCounter As Variant
    Dim oPartFlag As Boolean
    
    Erase prtNumsV
    arrivedTb.Text = ""
    partNumLB.Clear
    ListBox1.Clear


'check to see if arrived parts filter box is checked
    If partFilter = True Then
        Call vendorLBn_Click
        Exit Sub
    End If


'clear box data
        serialNumTB = ""
        partQtyTB = ""
        partRevTB = ""
        lotBatchTB = ""
        jobProOrderTB = ""
        supplierTB = ""
    
    venPicked = vendorLB.Value
'get number of populated rows total
    Dim data As Range
    Dim r As Variant
    Dim k As Variant


[COLOR=#ff0000]        Set data = Sheet1.Range("c1:c" & Range("c" & Rows.Count).End(xlUp).Row)[/COLOR]
[COLOR=#ff0000]                cntrV = 0[/COLOR]
[COLOR=#ff0000]            For Each r In data[/COLOR]
[COLOR=#ff0000]                cntrV = cntrV + 1[/COLOR]
[COLOR=#ff0000]                    If r.Offset(1) = vbNullString And r.Offset(2) = vbNullString Then[/COLOR]
[COLOR=#ff0000]                    End If[/COLOR]
[COLOR=#ff0000]            Next r[/COLOR]


'get number of times selected customer appears on sheet
    y = 0
    venCounter = 0
    For t = 1 To cntrV + 1
        If UCase(venPicked) = UCase(Cells(t, 9)) And UCase(Mid(Cells(t, 12), 1, 7)) <> "ARRIVED" Then
            venCounter = venCounter + 1
        End If
    Next
    
On Error Resume Next
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Do any of the cells in column C appear as ##### in the sheet?
 
Upvote 0
yes, thats just cause the column is not expanded. does that make a difference? i would think thats just a visual from formating
 
Upvote 0
Are you sure that's the cause?
 
Upvote 0
Do the following in order to isolate the overflow to the precise statement and conditions.

1. Enter the following statement higher up -- ideally, the first executable statement:

On Error GoTo oops

2. Enter the following statements at the end of the procedure:

Exit Sub
oops:
Stop
Resume

3. Select the On Error Resume Next statement, and press f9 to set a breakpoint in order to ensure that you do not reach that point.

4. Run the procedure.

5. When you get to the Stop statement, press f8 repeatedly to execute the Resume statement and return to the offending statement.

6. At the offending statement, look at the variable values. If you need further assistance, show us the offending statement and all relevant values.
 
Upvote 0
joeu,

i did your procedures and that it stops at this line

Code:
[COLOR=#FF0000] If r.Offset(1) = vbNullString And r.Offset(2) = vbNullString Then[/COLOR]
 
Upvote 0
I mean are you sure it's just the column width causing the ## signs and not a cell formatted as date with a too large number in it (which would cause exactly your error)?
 
Upvote 0
I mean are you sure it's just the column width causing the ## signs and not a cell formatted as date with a too large number in it (which would cause exactly your error)?


sir, you're a scholar and a gentleman. that was exactly it. there WAS one freaking row that wasnt just a visual display due to small column width.

thanks for your help guys
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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