+ Reply to Thread
Results 1 to 11 of 11

Explain me is different as value and application.index

  1. #1
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,449

    Explain me is different as value and application.index

    Please Login or Register  to view this content.
    what is different a and b
    a =Application.Index(Range("A2:E2").Value, 0, 0)
    b = Range("A2:E2").Value
    Last edited by daboho; 02-04-2018 at 07:51 AM.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Explain me is different as value and application.index

    Together are wrong
    a and b are integers
    a is using the EXCEL INDEX function to address a value in a range (A2 to E2) and as far as is waitting only one value back for a you should use
    a = Application.Index(Range("A2:E2").Value, 1, 1) to read the first value
    b is waitting for only one value and Range("A2:E2") stands for 5 values
    you should use b = Range("A2:E2").cells(1,1) to get the first one
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,449

    Re: Explain me is different as value and application.index

    Thank for your attention PCI
    I am use
    Debug.print a
    Result
    a(1)
    a(2)
    a(3)
    a(4)
    a(5)
    '------
    debug.print b
    Result in local window
    b(1,1)
    b(1,2)
    b(1,3)
    b(1,4)
    b(1,5)
    '_______
    If loop
    Please Login or Register  to view this content.
    Result
    Value in a2:e2
    '-------------
    Please Login or Register  to view this content.
    Result error
    Is diffrent a and b Only position ??
    a as column (vertikal)
    b as rows (horizontal)
    Last edited by daboho; 02-04-2018 at 07:55 AM.

  4. #4
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Explain me is different as value and application.index

    Quote Originally Posted by PCI View Post
    ... a and b are integers ...
    Actually, this statement:
    Please Login or Register  to view this content.
    ... specifies only i as long. a and b are unspecified for type, so they default to variants, which can contain arrays of values. The difference between a and b lies in the number of dimensions of their respective arrays. INDEX returns a 1- dimensional array in a, whereas directly assigning a range to b results in a 2-dimensional array (regardless of the fact that it's a single row of cells!)

    Run the following code. It errors when attempting to access the second dimension for a.
    Please Login or Register  to view this content.
    Last edited by leelnich; 02-04-2018 at 08:00 AM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,548

    Re: Explain me is different as value and application.index

    Daboho - post #3 does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Explain me is different as value and application.index

    Application.Index allows you to make use of the full capabilities of the Excel's INDEX function - very useful with multi-dimensional arrays
    For example, read this - Slicing an Array Without Loop – Application.Index

    EDIT
    Sorry Ali
    - your intervention crept in when my back was turned
    Last edited by kev_; 02-04-2018 at 08:00 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  7. #7
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Explain me is different as value and application.index

    Quote Originally Posted by daboho View Post
    ...
    Please Login or Register  to view this content.
    You have to reference BOTH dimensions, as above.
    Last edited by leelnich; 02-04-2018 at 08:09 AM.

  8. #8
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,449

    Re: Explain me is different as value and application.index

    Leelnich
    That is only dimensional array
    I want ask you again
    Is my oponion bellow is true ?
    Advantage (a)
    Can combine with application.join
    But (b) can not to combine with application.join

  9. #9
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,449

    Re: Explain me is different as value and application.index

    Kev thank i has read that

  10. #10
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,449

    Re: Explain me is different as value and application.index

    Thank all everybody
    I know that

  11. #11
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Explain me is different as value and application.index

    I'm not sure what you're asking. Yes, The VBA Join function requires a 1-dimensional array as its argument, so a (= App.Index) works, whereas b (assigned directly) does not. I avoid Index unless it serves a specific purpose, because it's slower to run AND extra typing.

+ 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. Explain Syntax [of INDEX with Evaluate]
    By sohaila in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-30-2017, 11:13 AM
  2. Replies: 3
    Last Post: 04-04-2017, 04:52 PM
  3. [SOLVED] Please Explain this Weird INDEX-MATCH Formula
    By omaral in forum Excel General
    Replies: 3
    Last Post: 01-12-2015, 07:56 PM
  4. Explain Application.Caller and OnAction
    By shawnvw in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-24-2014, 06:11 AM
  5. [SOLVED] Explain Index Match formula
    By ddub25 in forum Excel General
    Replies: 13
    Last Post: 06-21-2012, 04:32 AM
  6. Move/Index Application
    By Grandpa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-15-2012, 02:13 PM
  7. Explain index sumif formula
    By shopgirl1977 in forum Excel General
    Replies: 9
    Last Post: 12-17-2009, 12:14 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