Link to home
Start Free TrialLog in
Avatar of Seamus2626
Seamus2626Flag for Ireland

asked on

Sub error

Hi,

When i run the below code i get the error

"Object Variable or with Variable not set"

Does anyone know how to resolve this?

Thanks
Seamus
Sub SumUpForTable2()
        Dim FoundCell As Range

        Sheets("Corporate Actions").Select
        Range("B3").Select

        Do Until ActiveCell.Value = ""
            mysheetname = ActiveCell.Text
            Sheets(mysheetname).Select
            If Range("A2").Value = "" Then

                Sheets("Corporate Actions").Select
                ActiveCell.Offset(0, 1).Value = "0"
                ActiveCell.Offset(0, 2).Value = "0"
                ActiveCell.Offset(1, 0).Select
            Else
            
   
                FoundCell = Columns("C:C").Find(What:="Grand Total", LookIn:=xlValues, _
                    lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                    MatchCase:=False, SearchFormat:=False)
            End If
            With FoundCell
                .Offset(0, 7).Select
                ActiveCell.Resize(1, 2).Select
                Selection.Copy
                Sheets("Corporate Actions").Select
                ActiveCell.Offset(0, 1).PasteSpecial Paste:=xlPasteValues
            End With
        Loop
        Range("C3:C23").Select
        Selection.NumberFormat = "#,##0"
    End Sub

Open in new window

Avatar of Seamus2626
Seamus2626
Flag of Ireland image

ASKER

It debugs on

           
   
                FoundCell = Columns("C:C").Find(What:="Grand Total", LookIn:=xlValues, _
                    lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                    MatchCase:=False, SearchFormat:=False)
ASKER CERTIFIED SOLUTION
Avatar of kgerb
kgerb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect! Thanks Kyle

Seamus
You're welcome.  I've only done that about a million times. :)

Kyle