+ Reply to Thread
Results 1 to 9 of 9

Range (Is not working in excel 2010, but it is in excel 2016)

  1. #1
    Registered User
    Join Date
    06-24-2017
    Location
    Rio de Janeiro, Brazil
    MS-Off Ver
    Office 2010
    Posts
    3

    Range (Is not working in excel 2010, but it is in excel 2016)

    Hi, I'm new in the VBA. I'm trying to fill values from two different columns (G50 down) and (H50 down) with some random numbers based on other cell values, but i'm receiving "runtime error 1004 application defined or object defined" when i use this syntax:

    Please Login or Register  to view this content.
    You can download my excel at http://anovabr.com/wp/wp-content/upl...do-efeito.xlsm

    Works fine on excel 2016, but no on excel 2010.
    Thanks much!

  2. #2
    Valued Forum Contributor
    Join Date
    06-02-2012
    Location
    London, England
    MS-Off Ver
    365
    Posts
    397

    Re: Range (Is not working in excel 2010, but it is in excel 2016)

    In what way doesn't it work for you in Excel 2010?

    I'm using that version and it seems to work perfectly well for me.

    Do you get an error message or just not the results you expect?
    If an error message, which one and on what line of code?

    B

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Range (Is not working in excel 2010, but it is in excel 2016)

    I tested in Excel 2003 and it works fine as well. There must be another issue other than version.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Valued Forum Contributor
    Join Date
    06-02-2012
    Location
    London, England
    MS-Off Ver
    365
    Posts
    397

    Re: Range (Is not working in excel 2010, but it is in excel 2016)

    Also tested in Excel 2007! Still working there.

    B.

  5. #5
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Range (Is not working in excel 2010, but it is in excel 2016)

    Code works fine with my Office 2010 as well as Office 2016.
    So it's probably not a problem in the code.
    This error is notorious for it's cause can be a lot of things.

    Did you try to step thru to code and see what line triggers the error?

    Also Excel's internal admin is not waterproof and may get somewhat ambigeous.
    You might create a new workbook and copy range C2:Q51 (incl. the objects and the macro).
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

  6. #6
    Registered User
    Join Date
    06-24-2017
    Location
    Rio de Janeiro, Brazil
    MS-Off Ver
    Office 2010
    Posts
    3

    Re: Range (Is not working in excel 2010, but it is in excel 2016)

    Wow! Thanks, guys, for the reply.
    I'm receiving this message:

    "Application-defined or object-defined error"

    For this line

    Private Sub CommandButton1_Click()
    Range("G51:G2000").ClearContents
    Range("H51:H2000").ClearContents
    n1 = 49 + [H19]
    --->> Range("G50:G" & n1).Formula = "=NormInv(Rand(), " & [H17] & "," & [H18] & ")" << ----
    n2 = 49 + [K19]
    Range("H50:H" & n2).Formula = "=NormInv(Rand(), " & [K17] & "," & [K18] & ")"

    [I25] = "O Teste T (amostras independentes) chegou ao p valor de " & Round([D23], 2) _
    & " com tamanho de efeito de " & Round([E23], 2) & "."

    End Sub

    imagem 1.PNG

    When i change the order of syntax or change the code trying to fix it, the message appears to this command: "Range..."

    I'm using office 2010.

    Thanks again.

  7. #7
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Range (Is not working in excel 2010, but it is in excel 2016)

    What's the value of n1 at that point?
    That might result in an invalid range.
    But then again, that should be a problem for 2016 to
    Last edited by Tsjallie; 06-24-2017 at 04:48 PM.

  8. #8
    Registered User
    Join Date
    06-24-2017
    Location
    Rio de Janeiro, Brazil
    MS-Off Ver
    Office 2010
    Posts
    3

    Re: Range (Is not working in excel 2010, but it is in excel 2016)

    Hi all,
    I'm using, now, this code:
    Please Login or Register  to view this content.
    I figured out the problem:

    VBA is configured to use DOT as decimal separator; my excel formulas is configured to use COMMA as separator.
    See images below.

    Here, i'm using dots. None of my formulas work, but VBA works fine
    working.PNG

    Here, i'm using comma as decimal separator. VBA doesnt work anymore:
    working2.PNG

    working3.PNG

    If someone wants to try, i attached my excel file in this message.
    https://www.dropbox.com/s/4lre2o6h12...g%29.xlsm?dl=0

  9. #9
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Range (Is not working in excel 2010, but it is in excel 2016)

    Great find! That would never have crossed my mind (though weird things are crossing)
    Thx for feeding back!

+ 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. 2010 Macro not working in 2016 Excel
    By porepiga in forum Excel General
    Replies: 7
    Last Post: 04-18-2017, 12:11 PM
  2. Opening Excel 2010 in 2016 causes double images
    By tlshook in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-28-2016, 12:48 PM
  3. [SOLVED] today() in Excel 2010 32 bit vba returns different value than Excel 2016 64bit
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-10-2016, 12:34 PM
  4. VBA surrounding embedding Google Maps in Excel not working in excel 2016
    By Dtrix in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-09-2016, 07:04 PM
  5. Replies: 0
    Last Post: 05-17-2016, 12:39 PM
  6. Replies: 2
    Last Post: 05-17-2016, 12:23 PM
  7. Excel 2010 vs. Excel 2016 Slicer
    By mycon73 in forum Excel General
    Replies: 0
    Last Post: 03-18-2016, 12:40 AM

Tags for this Thread

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