+ Reply to Thread
Results 1 to 10 of 10

Application or Object defined error

  1. #1
    Registered User
    Join Date
    02-09-2012
    Location
    Manassas, Virginia, USA
    MS-Off Ver
    Excel 2007
    Posts
    30

    Application or Object defined error

    Hi Friends,

    I need to look for a match between Column A of 'DRAM' worksheet and Column A of 'Refer' worksheet and if a match is found then the row containing the match should be stored in a variable 'Cell1' and then my code must look for a string 'WS Group Totals:" in Column B of 'DRAM' sheet and the row containing the string must be stored in a variable Cell2. In the row containing Cell2 the values from Column D till the row end must be multiplied by 10080 and the result must be placed two rows below the last populated row in their respective columns. Once that is done my code must look for the next match of Column A in 'DRAM' and COLUMN A in 'Refer' worksheets and must do the calculation as the same as above. I have written the below code for the purpose but I am repeatedly getting Application or Object defined error...can someone please help me figure out the error...thank you very much..I have attached the original Workbook for your reference...

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by shrimic; 02-20-2012 at 12:53 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Application or Object defined error

    Hello shrimic ,

    The problem is with how you are using the Find method. Find returns a Range object if the search was successful. If not then it returns the special object Nothing. You should always check the result of the Find before you attempt to get the address, row or column.

    Try this corrected version of your macro...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-09-2012
    Location
    Manassas, Virginia, USA
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Application or Object defined error

    Hello Leith Ross,

    Thank you very much for your help...
    I tried the change but the problem still seems to continue "Its giving me 'Run Time Error 1004: Application defined or Object defined error"...The code breaks when it reaches the line
    ' Set PartRngWorkbook1Reference1 = Worksheets("Refer").Range("A", Worksheets("Refer").Range("A65536").End(xlUp))'....

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Application or Object defined error

    Hello ,

    You did not specify a row for "A" . I have inserted "A1" into the code. Change the starting address if you need to.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-09-2012
    Location
    Manassas, Virginia, USA
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Application or Object defined error

    Thank you Leith Ross,

    I have change the below in code:
    Please Login or Register  to view this content.
    Now the code is throwing up an error: 91 Object Variable or With block variable not set...
    It is breaking at the line:
    Found = PartRngWorkbook1DRAMSheetb.Find("WS Group Totals:", Range("B", Cell1))
    Can you please help
    Last edited by Leith Ross; 02-20-2012 at 01:55 PM. Reason: Added Code tags

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Application or Object defined error

    Hello shrimic,

    Sorry, that was my fault. There should be a Set statement in front of both Found variables ...
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-09-2012
    Location
    Manassas, Virginia, USA
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Application or Object defined error

    Thank you very much Leith Ross,
    Sorry to disturb you again. I changed the below lines in the code:

    Please Login or Register  to view this content.
    Now it is breaking at the line:
    If Found is Nothing then GoTo NextCell Else Cell2=Found.Row

    It is throwing up the error 'Application or Object defined error"...

  8. #8
    Registered User
    Join Date
    02-09-2012
    Location
    Manassas, Virginia, USA
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Application or Object defined error

    Thank you very much Leith Ross,
    Sorry to disturb you again. I changed the below lines in the code:

    Code:
    Please Login or Register  to view this content.
    Now it is breaking at the line:
    If Found is Nothing then GoTo NextCell Else Cell2=Found.Row

    It is throwing up the error 'Application or Object defined error"...
    Last edited by Leith Ross; 02-20-2012 at 02:38 PM. Reason: Added Code Tags

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Application or Object defined error

    Hello shrimic,

    You need to specify the starting cell in column "B". I have inserted "B1" into the code below. Change this address if you need to.
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    02-09-2012
    Location
    Manassas, Virginia, USA
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Application or Object defined error

    Thank you Leith Ross, I figured out where I was erring
    Actually the problem was in:

    Found = PartRngWorkbook1DRAMSheetb.Find("WS Group Totals:", Range("B", Cell1))
    it has to be:
    Found = PartRngWorkbook1DRAMSheetb.Find("WS Group Totals:", Range("B"& Cell1))

    Just the '&' threw up the error...thanks for your help Leith

+ Reply to Thread

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