+ Reply to Thread
Results 1 to 14 of 14

Error code : Application-defined or object-defined error ?

  1. #1
    Forum Contributor
    Join Date
    03-08-2021
    Location
    thailand
    MS-Off Ver
    2016
    Posts
    117

    Error code : Application-defined or object-defined error ?

    Now I have macro as below.


    Please Login or Register  to view this content.
    But after run , it show error Application-defined or object-defined error in line Cells(2, 6).Resize(UBound(a)) = a


    Please guide me about it.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    03-19-2022
    Location
    TBD
    MS-Off Ver
    O365
    Posts
    46

    Re: Error code : Application-defined or object-defined error ?

    Not sure what you want to do, but the error is because you assign Cells(2,6).Resize(Ubound(a)) to a.
    If you change that line to a = Cells(2,6).Resize(Ubound(a)), the error will disappear, but not sure that the code will work as what you want or not.

  3. #3
    Forum Contributor
    Join Date
    03-08-2021
    Location
    thailand
    MS-Off Ver
    2016
    Posts
    117

    Re: Error code : Application-defined or object-defined error ?

    I want to calculate value by column FPP divide value column Case.
    Attached Images Attached Images

  4. #4
    Registered User
    Join Date
    03-19-2022
    Location
    TBD
    MS-Off Ver
    O365
    Posts
    46

    Re: Error code : Application-defined or object-defined error ?

    I've revised your code as below:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-08-2021
    Location
    thailand
    MS-Off Ver
    2016
    Posts
    117

    Re: Error code : Application-defined or object-defined error ?

    I want output show number after cal only.
    Now Show formula in tab function.

    Please guide me more about it.
    Attached Images Attached Images

  6. #6
    Registered User
    Join Date
    03-19-2022
    Location
    TBD
    MS-Off Ver
    O365
    Posts
    46

    Re: Error code : Application-defined or object-defined error ?

    You can change a.Cells(i, 6).FormulaR1C1 = "=RC[-1]/RC[-2]" to a.Cells(i, 6) = a.Cells(i, 5) / a.Cells(i, 4) in order to get a static value.
    This code may cause slowness on large data (50k rows+) due to the loop that inputs a value directly on each cell.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-19-2022
    Location
    TBD
    MS-Off Ver
    O365
    Posts
    46

    Re: Error code : Application-defined or object-defined error ?

    This one is the faster version if your data size is large:

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Error code : Application-defined or object-defined error ?

    Why do you need a code for this simple task which could be done by a formula?

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    03-08-2021
    Location
    thailand
    MS-Off Ver
    2016
    Posts
    117

    Re: Error code : Application-defined or object-defined error ?

    After run your code , I found error overflow in line vFYP(i, 1) = vFPP(i, 1) / vCase(i, 1)


    Please Login or Register  to view this content.
    I think some value in vFPP and vCase = o

    How to solve it?
    Attached Images Attached Images
    Last edited by adamasmay; 03-20-2022 at 10:20 AM.

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Error code : Application-defined or object-defined error ?

    It is due to bottom has zero or error value. Have you tried my code?

  11. #11
    Forum Contributor
    Join Date
    03-08-2021
    Location
    thailand
    MS-Off Ver
    2016
    Posts
    117
    Quote Originally Posted by AB33 View Post
    It is due to bottom has zero or error value. Have you tried my code?
    If​ I​ want​ edit​ your​ code​ from​ =IF(RC[-2]=0,0,RC[-1]/RC[-2]) to​ use​ index​ column​ (column​ a=1,column​ c=3)

    How​ to​ edit​ it

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Error code : Application-defined or object-defined error ?

    Please Login or Register  to view this content.
    OR your code
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    03-19-2022
    Location
    TBD
    MS-Off Ver
    O365
    Posts
    46

    Re: Error code : Application-defined or object-defined error ?

    Hi adamasmay,

    It is dividing by zero error, please amend as below

    Please Login or Register  to view this content.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Error code : Application-defined or object-defined error ?

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by jindon; 03-20-2022 at 11:55 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. HELP WITH ERROR CODE '1004' Application-defined or object defined error
    By QuintonMcCloud in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-20-2015, 03:34 PM
  2. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  3. Previously working code is now is now giving Application-defined or object-defined error
    By ready2learn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2014, 07:22 PM
  4. [SOLVED] VBA Application-defined or Object-defined error on an unknown line of code.
    By kyleg222 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2012, 10:19 AM
  5. Pivot Cache VBA code - Application-defined or Object Defined error
    By 4am in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2011, 02:21 PM
  6. [SOLVED] Application-Defined or Object-Defined Error on simple code
    By Fid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2005, 04:05 PM
  7. [SOLVED] Application-Defined or Object-Defined Error on simple code
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-22-2005, 05:06 PM

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