+ Reply to Thread
Results 1 to 7 of 7

Run-time error '424': Object-required

Hybrid View

narrowgate88 Run-time error '424':... 07-12-2010, 10:29 AM
Leith Ross Re: Run-time error '424':... 07-12-2010, 11:45 AM
narrowgate88 Re: Run-time error '424':... 07-12-2010, 11:49 AM
Leith Ross Re: Run-time error '424':... 07-12-2010, 11:59 AM
narrowgate88 Re: Run-time error '424':... 07-12-2010, 12:06 PM
Leith Ross Re: Run-time error '424':... 07-12-2010, 12:17 PM
narrowgate88 Re: Run-time error '424':... 07-12-2010, 12:22 PM
  1. #1
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Lincoln, IL
    MS-Off Ver
    365
    Posts
    242

    Run-time error '424': Object-required

    I'm getting a run-time error at the "Delete Cash" portion of my code. Do I need to define something else?

    ' ==============================================================================================================
    ' Define Variables
        Dim Month As String, Year As String, Home As String, MonthEnd As String, FY As String
        Dim oSh As Worksheet
        Set oSh = ActiveSheet
        Dim x As Variant, y As Variant
        Dim Newbook
        
        FY = "FY10"
        Year = cboYear
        Home = "SCNC"
        
        Select Case cboMonth.Value
            Case "JANUARY"
                Month = "01"
                MonthEnd = "01/31/"
            Case "FEBRUARY"
                Month = "02"
                MonthEnd = "02/28/"
            Case "MARCH"
                Month = "03"
                MonthEnd = "03/31/"
            Case "APRIL"
                Month = "04"
                MonthEnd = "04/30/"
            Case "MAY"
                Month = "05"
                MonthEnd = "05/31/"
            Case "JUNE"
                Month = "06"
                MonthEnd = "06/30/"
            Case "JULY"
                Month = "07"
                MonthEnd = "07/31/"
            Case "AUGUST"
                Month = "08"
                MonthEnd = "08/31/"
            Case "SEPTEMBER"
                Month = "09"
                MonthEnd = "09/30/"
            Case "OCTOBER"
                Month = "10"
                MonthEnd = "10/31/"
            Case "NOVEMBER"
                Month = "11"
                MonthEnd = "11/30/"
            Case "DECEMBER"
                Month = "12"
                MonthEnd = "12/31/"
        End Select
    ' ==============================================================================================================
    ' Print the completed userform for the accountant's records.
    '    frmRSCV.printform
    ' ==============================================================================================================
    ' Open the file created by Billing.
            Workbooks.OpenText Filename:= _
                "I:\Dept\Accounting\Facility AR Reconciliations\AR Import Files\" & Home & "_" & Year & "" & Month & ".xlsm" _
                , Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
                xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
                Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 9), _
                Array(2, 3), Array(3, 1), Array(4, 9), Array(5, 1), Array(6, 9), Array(7, 1), Array(8, 1), _
                Array(9, 1), Array(10, 9)), TrailingMinusNumbers:=True
    ' ==============================================================================================================
    ' Create BatchID column.
        Range("Table1[[#Headers],[Location]]").FormulaR1C1 = "Batch"
        With ActiveCell.Characters(Start:=1, Length:=5).Font
            .Name = "Calibri"
            .FontStyle = "Regular"
            .Size = 11
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorLight1
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        Range("A2").Select
        Cells.Replace What:="" & Home & "", Replacement:="" & Home & "" & Year & "" & Month & "AR", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
        Columns("A:A").EntireColumn.AutoFit
    ' ==============================================================================================================
    ' Delete all rows with a "Total" Value of 0.
        ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=8, Criteria1:="-"
        Application.DisplayAlerts = False
        ActiveSheet.UsedRange.Offset(1, 0).Resize(ActiveSheet.UsedRange.Rows.Count - 1).Rows.Delete
        Application.DisplayAlerts = True
        ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=8
        Range("Table1[[#Headers],[Batch]]").Select
    ' ==============================================================================================================
    ' Delete all rows with "Type" Value of 40 or 50.
        ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=3, Criteria1:= _
            "=40", Operator:=xlOr, Criteria2:="=50"
        Application.DisplayAlerts = False
        ActiveSheet.UsedRange.Offset(1, 0).Resize(ActiveSheet.UsedRange.Rows.Count - 1).Rows.Delete
        Application.DisplayAlerts = True
        ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=3
        Range("Table1[[#Headers],[Batch]]").Select
    ' ==============================================================================================================
    ' Convert PL Account to GP Account
        Workbooks.Open Filename:= _
            "I:\Dept\Accounting\Facility AR Reconciliations\PL GL #\PL GL Master (3).xlsx"
        Sheets("MASTER FY10").Select
        Sheets("MASTER FY10").Copy After:=Workbooks("" & Home & "_" & Year & "" & Month & ".xlsm").Sheets(2)
        Sheets("MASTER FY10").Name = "COA Conversion"
        Sheets("" & Home & "_" & Year & "" & Month & "").Select
        Columns("B:B").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        Range("B2").FormulaR1C1 = _
            "=VLOOKUP(Table1[[#This Row],[Account]],'COA Conversion'!C[-1]:C[6],8,FALSE)"
        Columns("B:B").NumberFormat = "0"
        Columns("B:B").EntireColumn.AutoFit
    ' ==============================================================================================================
    ' Identify Cash & AR Amount.
        ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2, Criteria1:= _
            "=100700", Operator:=xlOr, Criteria2:="=120000"
        Columns("C:H").EntireColumn.Hidden = True
        x = Application.InputBox _
                 (Prompt:="Enter 100700 amount shown on screen.", _
                        Title:="ENTER CASH AMOUNT", Type:=1)
        y = Application.InputBox _
                 (Prompt:="Enter 120000 amount shown on screen.", _
                        Title:="ENTER AR AMOUNT", Type:=1)
        Columns("C:H").EntireColumn.Hidden = False
    ' ==============================================================================================================
    ' Delete Cash row.
        Select Case x.Value
            Case Is <> ""
                ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2, Criteria1:="100700"
                Application.DisplayAlerts = False
                ActiveSheet.UsedRange.Offset(1, 0).Resize(ActiveSheet.UsedRange.Rows.Count - 1).Rows.Delete
                Application.DisplayAlerts = True
        End Select
                ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2
                Range("Table1[[#Headers],[Batch]]").Select
    Last edited by narrowgate88; 07-12-2010 at 12:22 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Run-time error '424': Object-required

    Hello narrowgate88,

    Since you didn't say which line in the code was producing the error, I have to guess. The statement to display alerts and the statement to select the used range are correct, which leaves the ListObject. Have you verified that the name "Table1" is the correct name for that object on the active sheet?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Lincoln, IL
    MS-Off Ver
    365
    Posts
    242

    Re: Run-time error '424': Object-required

    I'm sorry. It's erroring out at
    Select Case x.Value
    in the last section of the code shown above.

    I did think about the table name issue and the table is named correctly.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Run-time error '424': Object-required

    Hello narrowgate88,

    The Application.InputBox is a type 1, meaning it requires a number. Your Case statement is:
        Select Case x.Value
            Case Is <> ""
                ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2, Criteria1:="100700"
                Application.DisplayAlerts = False
                ActiveSheet.UsedRange.Offset(1, 0).Resize(ActiveSheet.UsedRange.Rows.Count - 1).Rows.Delete
                Application.DisplayAlerts = True
        End Select

    The Value statement can only be used with an object, not a string, nor a number.

  5. #5
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Lincoln, IL
    MS-Off Ver
    365
    Posts
    242

    Re: Run-time error '424': Object-required

    What I'm trying to accomplish is that if the value entered for x is zero, then the following portion of the code won't run.

    ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2, Criteria1:="100700"
                Application.DisplayAlerts = False
                ActiveSheet.UsedRange.Offset(1, 0).Resize(ActiveSheet.UsedRange.Rows.Count - 1).Rows.Delete
                Application.DisplayAlerts = True
    So, what are you telling me to do with the select case statement? I tried just removing the .Value, but it still ran the code even though I entered 0 for x.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Run-time error '424': Object-required

    Hello narrowgate88,

    You really need to do some reading about variable types. Your Case statement fails because it is looking to compare a String. The double quotes represents an empty string, not a numeric zero. If the Case statement does not test true then the next Case statement is evaluated, if there is one. Did you change the Case statement to look for a zero?
        Select Case x
            Case Is <> 0
                ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2, Criteria1:="100700"
                Application.DisplayAlerts = False
                ActiveSheet.UsedRange.Offset(1, 0).Resize(ActiveSheet.UsedRange.Rows.Count - 1).Rows.Delete
                Application.DisplayAlerts = True
        End Select

  7. #7
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Lincoln, IL
    MS-Off Ver
    365
    Posts
    242

    Re: Run-time error '424': Object-required

    Ugh. Duh, no I forgot to change it to zero. Works perfectly! Thank you. Will mark case solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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