Error Object Required

  • Good Day
    I'm having a problem with one of my subs. The code I'm using, is identical to code that I have in several common subs, (that are slightly different but the same idea) in my program; and they work fine. I can't figure out why it doesn't work. In the REM statements, of the code that I included below, I've identified the area of concern. I'm still a bit green and learning as I go.. I would really appreciate your help...Thanks in advance ...Here is the code:


    Purpose: I add rows to my table daily and want to delete from 600 rows from the end up to row 15. This in turn populates a chart.



    Very much appreciated...Jimmy

    Thanks for your help

    JimmyB


    Some plans fail on execution

    All plans fail without

    8)

  • Hi JimmyB,


    I'm guess that it has something to do with the "Dim" statements and the associated "Set" statements.


    Try amending


    Code
    Dim RngA as Double
    Dim FirstCell as Range 'or as Double
    Dim LastCell as Range 'or as Double


    Note the above Dim as statements will depend on what type of object you are trying to dimension (i.e. define) and subsequently set in the Set Statements


    Set FirstCell = RngA.Offset(-600, -3) what is that you want here (i.e. Cell Address, Row Number etc.).


    I am not a VB expert so hopefully this makes sense and helps you.


    If you attach a copy of the workbook, it would also help.


    As an alternative or look at the attached file which I based on code from [URL="http://Range(FirstCell,%20LastCell).Delete%20Shift:=xlUp"]stackoverflow [/URL]and my interpretation of the comments in your code.


    Regards,


    Gizzmo

  • The variables are explicitly declared so Excel will assign them as variables, so I doubt that is causing an issue,


    There's an unseen procedure which may cause the problem called here :

    Code
    Call Column4_FirstBlank


    See if this is better


  • Thanks so much Roy. I'll try it out tonight.
    Just to help clarify here is the code I use for the 'Call':


    Sub Column4_FirstBlank()


    Dim ws As Worksheet
    Set ws = ActiveSheet
    For Each Cell In ws.Columns(4).Cells
    If IsEmpty(Cell) = True Then Cell.Select: Exit For
    Next Cell
    End Sub


    I use this everywhere and it works.
    Thanks again Jimmy

    Thanks for your help

    JimmyB


    Some plans fail on execution

    All plans fail without

    8)

  • Hey Roy. It worked, but I did have to come from the top, using my Column4_FirstBlank Sub, instead of the end. I have a table below the rows of inputs that summarizes some of the data. Been struggling for hours! You're awesome. You are the MAN. Thanks again...Great Job

    Thanks for your help

    JimmyB


    Some plans fail on execution

    All plans fail without

    8)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!