+ Reply to Thread
Results 1 to 3 of 3

vba runtime error 1004 application defined or object defined error

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Office 365
    Posts
    124

    vba runtime error 1004 application defined or object defined error

    Something very strange happened. At one point this was working and all of a sudden now I get an error. The issue is fm and sm, when the debug is on, fm = Empty and sm = Empty Therefore tval = Empty the error occurs at line 34 ; tval = WorksheetFunction.Sum(ws.Range(ws.Cells(fm, 11), ws.Cells(sm, 11)))

    Private Sub TextBox6_Change()
    
    Dim ws As Worksheet
    Dim sr, leg, lr, fm, sm, tval, sval, i, j As Long       
    Dim wo, rc As String
    
    Set ws = ThisWorkbook.Worksheets("Cost Analysis")       ' ws = Work Sheet
    sr = 5                                                  ' sr = Start row
    lr = ws.Cells(Rows.Count, 1).End(xlUp).Row              ' lr = Last row
    wo = Trim(UserForm1.TextBox4.Value)                     ' Work Order
    leg = Trim(UserForm1.TextBox5.Value)                    ' leg
    rc = Trim(UserForm1.ComboBox3.Value)                    ' rc = Root Cause
    
    If wo <> "" And leg <> "" And rc <> "" And TextBox6.Value <> "" Then
    
    If Application.WorksheetFunction.CountIfs(ws.Cells(sr, 1).Resize(lr, 1), wo, _
                                                ws.Cells(sr, 4).Resize(lr, 1), leg, _
                                                ws.Cells(sr, 5).Resize(lr, 1), rc) > 0 Then
    
            For i = sr To lr
                    If Trim(ws.Cells(i, 1)) = wo And Trim(ws.Cells(i, 4)) = leg Then
                        j = j + 1
                            If j = 1 Then
                                fm = i
                            End If
                                If Trim(ws.Cells(i, 5)) = rc Then
                                        sm = i
                                        Exit For
                                              Else
                                End If
                    End If
            Next
    
            tval = WorksheetFunction.Sum(ws.Range(ws.Cells(fm, 11), ws.Cells(sm, 11)))
            sval = WorksheetFunction.Sum(ws.Range(ws.Cells(fm, 11), ws.Cells(sm, 11))) * Trim(TextBox6.Value)
    
                Else
     End If
    End If
    
    UserForm1.TextBox7 = tval
    UserForm1.TextBox16 = sval
    
    End Sub
    Attached Images Attached Images
    Last edited by YuriyBaron; 05-09-2018 at 03:41 PM.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    8,031

    Re: vba runtime error 1004 application defined or object defined error

    Would be easier to diagnose the issue if we could see the workbook.
    Any chance you could attach a desensitized version?

    BSB

  3. #3
    Forum Contributor
    Join Date
    08-10-2016
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Office 365
    Posts
    124

    Re: vba runtime error 1004 application defined or object defined error

    Unfortunately, the file is too large with sensitive information. Everything is also connected to SQL.

+ 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. Runtime error 1004 application-defined object-defined
    By stevoDE in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2017, 09:58 AM
  2. Replies: 5
    Last Post: 08-19-2015, 07:10 PM
  3. [SOLVED] Runtime error 1004 - Application-defined or object-defined error
    By missit in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-15-2014, 03:40 AM
  4. Replies: 0
    Last Post: 05-14-2012, 11:59 PM
  5. Runtime error '1004' Application-defined or object-defined error Comment
    By Willer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-17-2011, 03:02 PM
  6. RE: Runtime error 1004- application defined or object defined erro
    By Novice in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2006, 05:40 PM
  7. RE: Runtime error 1004- application defined or object defined erro
    By Jim Thomlinson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-06-2006, 05:35 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