• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Loop with Array Formula in VBA

Hii everyone in need to loop through a range and get the values in 2 column (using index match maybe.)

My current formula works for 1 cell But i don't know how to use a for loop with it?

Also when i run the code it pastes the formula in it. I don't want any formula pasted in the cells, but only values. (If that is possible)

Please help! thanks in advance.
 

Attachments

  • Test.xlsm
    15.8 KB · Views: 13
Hi !

No needs loop ! Just a correct formula :​
Code:
Sub Demo1()
    With [I8:I11]
        .Cells(1).FormulaArray = "=INDEX($B$6:$H$45,MATCH(G8&H8,$C$6:$C$45&$B$6:$B$45,0),3)"
        .Cells(1).AutoFill .Cells
        .Formula = .Value
    End With
End Sub
Do you like it ? So thanks to click on bottom right Like !
 
and since you're probably wanting to do this for two columns:
Code:
Sub Demo1()
    With [I8:J11]
        .Cells(1).FormulaArray = "=INDEX(D$6:D$45,MATCH($G8&$H8,$C$6:$C$45&$B$6:$B$45,0))"
        .Cells(1).AutoFill .Rows(1)
        .Rows(1).AutoFill .Cells
        .Formula = .Value
    End With
End Sub
 
Thankyou mark And Pascal for your very quick response & sorry for my late Thanks.

Thankyou.

Actually this is just a part of my other problem. Autofill is not an option for me. i have to solve it using "for loop" method only. But anyways thanks. :)
 
Back
Top