+ Reply to Thread
Results 1 to 2 of 2

Run-Time Error 6: Overflow

Hybrid View

  1. #1
    Registered User
    Join Date
    08-12-2013
    Location
    Denton, Texas
    MS-Off Ver
    Excel 2010
    Posts
    89

    Run-Time Error 6: Overflow

    Hello,

    I'm getting a Run-Time Error 6: Overflow on the code below. It's strange because this code as been working perfect for 10 months and now it's spitting out this error. It stops on the "For Loop" where "R = Range("F" & p)". Can anyone please help me understand whats going wrong?

    Thank you!


    
    Dim i As Long
    Dim p As Long
    Dim Y As String
    Dim W As String
    Dim Z As String
    Dim LR As String
    Dim Cell As Range
    Dim intCol As Integer
    Dim NumDays As Integer
    Dim var1 As String
    
    var1 = "X"
    
    
    LR = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
    Today = Date
    NumDays = 10
    dateStamp = "12/31/2020"
    
    
    For p = 2 To LR
        X = Range("C" & p)
        X = Left(X, 1)
        R = Range("F" & p)
        R = Left(R, 10)
    
    
            For Each Cell In Range("F" & p)
                If Cell.Value = " " Then
                    Cell.Offset(0, 0).Value = dateStamp
                End If
            Next
            
            For Each Cell In Range("F" & p)
                If InStr(R, "-") Then
                    Cell.Offset(0, 0).Value = dateStamp
                End If
            Next
            
            If CDate(Cells(p, 6)) = Today + NumDays And X = var1 Then Range("C" & p).Font.Color = vbBlue
            
            
            'All cells in column loop that are marked are to mark the whole row that its in
            For Each Cell In Range("C" & p)
                If Cell.Font.Color = vbBlue Then
                    Cell.Offset(0, -1).Font.Color = vbBlue
                        Cell.Offset(0, -2).Font.Color = vbBlue
                            Cell.Offset(0, 1).Font.Color = vbBlue
                                Cell.Offset(0, 2).Font.Color = vbBlue
                                    Cell.Offset(0, 3).Font.Color = vbBlue
                End If
            Next
            
            
            ' All cells that haven't been marked are set to = ""
            If Range("F" & p).Font.Color <> vbBlue Then Range("F" & p).Value = ""
            For Each Cell In Range("F" & p)
                If Cell.Value = "" Then
                    Cell.Offset(0, -1).Value = ""
                        Cell.Offset(0, -2).Value = ""
                            Cell.Offset(0, -3).Value = ""
                                Cell.Offset(0, -4).Value = ""
                                    Cell.Offset(0, -5).Value = ""
                        
                End If
            Next
    '
    Next
    
    
    
    
        For intCol = 1 To 6 'cols A to F
            Range(Cells(2, intCol), Cells(p, intCol)). _
            SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp
        Next intCol
        
    
        Call BorderUp
        
    '        Sheets("Sheet1").Range("A1").Select
    '        Selection.CurrentRegion.Select
    '        Sheets("Sheet2").Select
    '        Sheets("Sheet2").Paste
    
    
            If Sheets("Sheet2").Range("B2").Value = "" Then Exit Sub
                
    
    
            Sheets("Sheet2").Range("A1").Select
            Selection.CurrentRegion.Select
            Selection.Copy
            Sheets("Sheet1").Select
            Range("A1").Select
            ActiveSheet.Paste
            
            Worksheets("Sheet2").Range("A:F").ClearContents
        
    
        
        Columns.AutoFit
        
    Application.ScreenUpdating = True

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Run-Time Error 6: Overflow

    Where is R declared?

    What's the cell value when that occurs?

    You calculate LR on Sheet2, but then all of the other code refers to the active worksheet, which may or may not be Sheet2.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Run-time error '6' overflow
    By tranxcop in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2015, 09:00 PM
  2. [SOLVED] run-time error 6: Overflow
    By a.hudrea in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-26-2015, 07:39 AM
  3. Run time error '6' , Overflow
    By PrashantS87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2015, 03:33 AM
  4. [SOLVED] Run-time error '6': Overflow
    By msawyer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-14-2012, 01:29 PM
  5. [SOLVED] Run Time Error '6'-OverFlow
    By mjali001 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-03-2012, 01:50 PM
  6. Run-time error '6': Overflow
    By johnlynches in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-02-2012, 12:07 PM
  7. Run-time error 6 : overflow
    By Mbrolass in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2007, 03:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1