Results 1 to 4 of 4

Run Time 424 Error - new to VBA

Threaded View

  1. #1
    Registered User
    Join Date
    08-25-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    23

    Run Time 424 Error - new to VBA

    Hello -

    My macro's objective is to determine if any 1 of 21 string values exists in a list passed to it. If yes, set the cell to the right to '1'.

    I defined 1 range (= list passed in, starting with first value and looping to end of list).

    I individually coded each of the 21 possible string values as I was not sufficiently skilled to 'double range'.


    Using code below, I am getting 'Run Time 424 - Object Required'

    Public Sub Test()
    
    Sheets("REGISTER").Select
    Dim Products As Range
    Set Products = Worksheet.Range("B13")   'CODE BREAKS HERE
    Dim FlatFee As String
    FlatFee = Products.Find(What:="GSBA95", After:=ActiveCell, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products = ""
    Exit Do
    Loop
    'End With
    
    If FlatFee <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products1 As Range
    Set Products1 = Range("B13").Select
    With Products1
    Set FlatFee1 = .Columns(1).Find(What:="RT1", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products1 = ""
    Exit Do
    Loop
    'End With
    If FlatFee1 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products2 As Range
    Products2 = Range("B13").Select
    With Products2
    Set FlatFee2 = .Columns(1).Find(What:="RT2", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products2 = ""
    Exit Do
    Loop
    'End With
    If FlatFee2 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products3 As Range
    Products3 = Range("B13").Select
    With Products3
    Set FlatFee3 = .Columns(1).Find(What:="CST1D", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products3 = ""
    Exit Do
    Loop
    'End With
    If FlatFee3 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products4 As Range
    Products4 = Range("B13").Select
    With Products4
    Set FlatFee4 = .Columns(1).Find(What:="RT3", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products4 = ""
    Exit Do
    Loop
    'End With
    If FlatFee4 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products5 As Range
    Products5 = Range("B13").Select
    With Products5
    Set FlatFee5 = .Columns(1).Find(What:="CST1M", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products5 = ""
    Exit Do
    Loop
    'End With
    If FlatFee5 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products6 As Range
    Products6 = Range("B13").Select
    With Products6
    Set FlatFee6 = .Columns(1).Find(What:="CST2D", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products6 = ""
    Exit Do
    Loop
    'End With
    If FlatFee6 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products7 As Range
    Products7 = Range("B13").Select
    With Products7
    Set FlatFee7 = .Columns(1).Find(What:="CST2M", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products7 = ""
    Exit Do
    Loop
    'End With
    If FlatFee7 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products8 As Range
    Products8 = Range("B13").Select
    With Products8
    Set FlatFee8 = .Columns(1).Find(What:="CST3D", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products8 = ""
    Exit Do
    Loop
    'End With
    If FlatFee8 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products9 As Range
    Products9 = Range("B13").Select
    With Products9
    Set FlatFee9 = .Columns(1).Find(What:="CST3M", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products9 = ""
    Exit Do
    Loop
    'End With
    If FlatFee9 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products10 As Range
    Products10 = Range("B13").Select
    With Products10
    Set FlatFee10 = .Columns(1).Find(What:="CST4D", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products10 = ""
    Exit Do
    Loop
    'End With
    If FlatFee10 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products11 As Range
    Products11 = Range("B13").Select
    With Products11
    Set FlatFee11 = .Columns(1).Find(What:="CST4M", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products11 = ""
    Exit Do
    Loop
    'End With
    If FlatFee11 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products12 As Range
    Products12 = Range("B13").Select
    With Products12
    Set FlatFee12 = .Columns(1).Find(What:="GSBA100", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products12 = ""
    Exit Do
    Loop
    'End With
    If FlatFee12 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products13 As Range
    Products13 = Range("B13").Select
    With Products13
    Set FlatFee113 = .Columns(1).Find(What:="CCT1D", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products13 = ""
    Exit Do
    Loop
    'End With
    If FlatFee13 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products14 As Range
    Products14 = Range("B13").Select
    With Products14
    Set FlatFee14 = .Columns(1).Find(What:="CCT1M", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=lPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products14 = ""
    Exit Do
    Loop
    'End With
    If FlatFee14 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products15 As Range
    Products15 = Range("B13").Select
    With Products15
    Set FlatFee15 = .Columns(1).Find(What:="CCT2D", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products15 = ""
    Exit Do
    Loop
    'End With
    If FlatFee15 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products16 As Range
    Products16 = Range("B13").Select
    With Products16
    Set FlatFee16 = .Columns(1).Find(What:="CCT2M", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products16 = ""
    Exit Do
    Loop
    'End With
    If FlatFee16 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products17 As Range
    Products17 = Range("B13").Select
    With Products17
    Set FlatFee17 = .Columns(1).Find(What:="CCT3D", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products17 = ""
    Exit Do
    Loop
    'End With
    If FlatFee17 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products18 As Range
    Products18 = Range("B13").Select
    With Products18
    Set FlatFee18 = .Columns(1).Find(What:="CCT3M", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products18 = ""
    Exit Do
    Loop
    'End With
    If FlatFee18 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products19 As Range
    Products19 = Range("B13").Select
    With Products19
    Set FlatFee19 = .Columns(1).Find(What:="CCT4D", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products19 = ""
    Exit Do
    Loop
    'End With
    If FlatFee19 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    Sheets("REGISTER").Select
    Dim Products20 As Range
    Products20 = Range("B13").Select
    With Products20
    Set FlatFee20 = .Columns(1).Find(What:="CCT4M", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    Do Until Products20 = ""
    Exit Do
    Loop
    'End With
    If FlatFee20 <> NullString Then ActiveCell.Offset(0, 1).Value = 1
    'End If
    
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    End With
    
    End Sub
    Where the code breaks, I have tried the following:

    Set Products = Worksheet.Range("B13")
    Products = Range("B13")
    Products = Range("B13").Value
    Set Products = Range("B13").Value
    Set Products = Range("B13").Select
    Products = Range("B13").Select

    I AM on IE6. There are no pivot charts involved.

    What am I doing wrong? Thanks.
    Attached Files Attached Files
    Last edited by Snoopy2010; 08-31-2010 at 05:04 PM.

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