1

Could anyone help me when and why I have to use the application.index in the VBA?

Function elso(bemenet)

Dim kimenet(), koztes() As Variant
Dim i, j, n, m, k As Long
Dim sarok As Double

elso = 1
n = bemenet.Rows.count
m = bemenet.Columns.count
ReDim kimenet(n + 1, m + 1)

For i = 1 To n
    For j = 1 To m
        kimenet(i, j) = bemenet(i, j)
    Next j
Next i

For i = 1 To n
    kimenet(i, m + 1) = Application.max(Application.Index(bemenet, i, 0))
Next i

For j = 1 To m
    kimenet(n + 1, j) = Application.Average(Application.Index(bemenet, 0, j))
Next j

For k = 1 To Application.max(n, m)
    sarok = sarok + (bemenet(k, k))
Next k

kimenet(n + 1, m + 1) = sarok
elso = kimenet

End Function
5
  • Function elso(bemenet) Dim kimenet(), koztes() As Variant Dim i, j, n, m, k As Long Dim sarok As Double elso = 1 n = bemenet.Rows.Count m = bemenet.Columns.Count ReDim kimenet(n + 1, m + 1) For i = 1 To n For j = 1 To m kimenet(i, j) = bemenet(i, j) Next j Next i For i = 1 To n kimenet(i, m + 1) = Application.Max(Application.Index(bemenet, i, 0)) Next i For j = 1 To m kimenet(n + 1, j) = Application.Average(Application.Index(bemenet, 0, j)) Next j Commented May 25, 2016 at 18:55
  • For k = 1 To Application.Max(n, m) sarok = sarok + (bemenet(k, k)) Next k kimenet(n + 1, m + 1) = sarok elso = kimenet End Function Commented May 25, 2016 at 18:55
  • Sorry, I'm new in here and I don't know how to show my VBA code in a 'normal' view. Commented May 25, 2016 at 18:56
  • Put the code in your question. Highlight it and then hit Ctrl + K Commented May 25, 2016 at 18:57
  • @EvelinDanás have a read of this page then please edit your question. Commented May 25, 2016 at 19:13

2 Answers 2

3

It's a worksheet function for pulling values from a range. The following function identically:

Application.Index(Array, Row_Number, Column_Number)

Application.WorksheetFunction.Index(Array, Row_Number, Column_Number)
Sign up to request clarification or add additional context in comments.

Comments

0

It seems to be for getting specific values stored in memory from worksheets. Please see https://usefulgyaan.wordpress.com/2013/06/12/vba-trick-of-the-week-slicing-an-array-without-loop-application-index/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.