0

I'm trying to place a formula in a range of cells using VBA. I have written the formula to do this and it works great, however, I would like to the formula to be dynamic. The range of data in which the formula searches is variable.

I want to do a use End(xlUp) to determine the range. The code I have is the following:

Range("P43").FormulaArray = "=IFERROR(INDEX(Input Tigerlijst!$A$2:$A$247,MATCH(1,--(SEARCH(TRANSPOSE(Input Tigerlijst!$A$2:$A$247),O43)>0),0),0),"""")"

What I think is the solution is:

Range("P43").FormulaArray = "=IFERROR(INDEX(Input Tigerlijst!$A$2:*LastRow*,MATCH(1,--(SEARCH(TRANSPOSE(Input Tigerlijst!$A$2:*LastRow*),O43)>0),0),0),"""")"

I've been searching and trying for hours, help would be greatly appreciated.

braX
  • 11,506
  • 5
  • 20
  • 33
HoekPeter
  • 11
  • 1
  • 1
  • 5

1 Answers1

0

"=IFERROR(INDEX(Input Tigerlijst!$A$2:$A$247,MATCH(1,--(SEARCH(TRANSPOSE(Input Tigerlijst!$A$2:$A$247),O43)>0),0),0),"""")"

can be written as

"=IFERROR(INDEX(Input Tigerlijst!$A$2:$A$" & "247" & ",MATCH(1,--(SEARCH(TRANSPOSE(Input Tigerlijst!$A$2:$A$" & "247" & "),O43)>0),0),0),"""")"

or for clarity

"=IFERROR(INDEX(Input Tigerlijst!$A$2:$A$" & _
"247" & _
",MATCH(1,--(SEARCH(TRANSPOSE(Input Tigerlijst!$A$2:$A$" & _
"247" & _
"),O43)>0),0),0),"""")"`

which can finally be written as

"=IFERROR(INDEX(Input Tigerlijst!$A$2:$A$" & _
LastRow & _
",MATCH(1,--(SEARCH(TRANSPOSE(Input Tigerlijst!$A$2:$A$" & _
LastRow & _
"),O43)>0),0),0),"""")"`
Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250