what is different a and bPlease Login or Register to view this content.
a =Application.Index(Range("A2:E2").Value, 0, 0)
b = Range("A2:E2").Value
what is different a and bPlease Login or Register to view this content.
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.
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
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
ResultPlease Login or Register to view this content.
Value in a2:e2
'-------------
Result errorPlease Login or Register to view this content.
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.
Actually, this statement:... 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!)Please Login or Register to view this content.
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
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.
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
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
Kev thank i has read that
Thank all everybody
I know that
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks