Solved

Excel VBA run time error

Posted on 2013-11-05
4
607 Views
Last Modified: 2013-11-05
When the following statement is executed the error below occurs…
        ColLast = .Cells(4, .Columns.Count).End(xlToLeft).Column
Run-time error ‘424’;
Object required

Can anyone helpwith this?
Thanks in Advance

Code...

Sub UpdateData()
    Dim ColLast As Long, RowLast As Long
    Dim AppendStr As String, Str As String
    Dim RowIndex As Long, ColIndex As Long
   

    With ActiveSheet.Name 'Sheet1
        ColLast = .Cells(4, .Columns.Count).End(xlToLeft).Column
        RowLast = .Cells(.Rows.Count, "D").End(xlUp).Row
        Dim StrArray() As String, i As Integer
               
        For RowIndex = 5 To RowLast
            AppendStr = ""
           
            i = 0
            For ColIndex = 2 To ColLast
                If .Cells(4, ColIndex) = "Regulatory" And .Cells(3, ColIndex).Interior.ColorIndex <> 43 Then
                    Str = .Cells(RowIndex, ColIndex)
                    If i = 0 Then
                        AppendStr = Str
                        ReDim Preserve StrArray(i)
                        StrArray(UBound(StrArray)) = Str
                        i = i + 1
                    ElseIf UBound(Filter(StrArray, Str)) <= -1 Then
                        AppendStr = AppendStr & ", " & Str
                        ReDim Preserve StrArray(i)
                        StrArray(UBound(StrArray)) = Str
                        i = i + 1
                    End If
                End If
            Next ColIndex
           
            .Cells(RowIndex, 1) = AppendStr
        Next RowIndex
       
    End With

End Sub
0
Comment
Question by:tesla764
  • 2
4 Comments
 
LVL 45

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
Comment Utility
Try this:

RowLast  = Cells.Find("*", SearchOrder:=xlByColumns, LookIn:=xlValues, SearchDirection:=xlPrevious).Column
0
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 250 total points
Comment Utility
Hi,

...or, change:

With ActiveSheet.Name 'Sheet1

To read:

With ActiveSheet

BFN,

fp.
0
 

Author Closing Comment

by:tesla764
Comment Utility
Both of these solutions worked.
Thanks everybody.
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now