Consulting

Results 1 to 4 of 4

Thread: Run time error 424 object required

  1. #1
    VBAX Regular
    Joined
    Apr 2012
    Posts
    22
    Location

    Run time error 424 object required

    While running this macro, I am getting error. Can anybody help me
    Sub abc()
        Dim score As Double
        Dim grade As String
        Dim i As Integer
        For i = 5 To Sheet1.Range("N65536").End(xlUp).Row 'assuming you start at row 1
        score = Sheet1.Cells(i, 14)
        Select Case score
            Case Is < 0.0001
                grade = "Very Rare"
            Case Is < 0.001
                grade = "Rare"
            Case Is < 0.01
                grade = "Uncommon"
            Case Is < 0.1
                grade = "Common"
            Case Else
                grade = "Very Common"
        End Select
        Sheet1.Cells(i, 15) = grade
        Next i
    End Sub
    Attached Files Attached Files
    Last edited by Bob Phillips; 06-15-2012 at 01:32 AM. Reason: Added VBA tags

  2. #2
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    try changing sheet1 to Sheets(1)
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sheet1 should work, except you do not have a sheet with a codename of Sheet1, your sheet is Sheet2.

    I would explicitly use the sheet name

    Sub abc() 
    Dim score As Double 
    Dim grade As String 
    Dim i As Integer 
    With Worksheets("Overview")
        For i = 5 To .Range("N65536").End(xlUp).Row 'assuming you start at row 1
            Select Case .Cells(i, 14) 
                Case Is < 0.0001 
                    grade = "Very Rare" 
                Case Is < 0.001 
                    grade = "Rare" 
                Case Is < 0.01 
                    grade = "Uncommon" 
                Case Is < 0.1 
                    grade = "Common" 
                Case Else 
                    grade = "Very Common" 
            End Select 
            .Cells(i, 15) = grade 
        Next i 
    End With
    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Regular
    Joined
    Apr 2012
    Posts
    22
    Location
    Thank you very much

Posting Permissions

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