0

I have already found the row index of a cell using VBA code. But I now I need to find an average of values in the cells from an index to another index. To find average, I know i can use application.worksheetfunction.average() but how do I combine the column and row index. The row index is a variable while the column is B for example.

For example, I need to find the average between startIndex to endIndex

Code:application.worksheetfunction.average("BstartIndex:BendIndex").

Is this right?

1 Answer 1

2

Application.WorksheetFunction.Average("B" & startIndex & ":B" & endIndex)

Basically, what you want to do is concatenate all components of the range string to insert into the function call. You cannot refer to variables inside a string in VBA, to my knowledge.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.