# How can apply "LastRow" in the formula

#### motilulla

##### Well-known Member
Hello,

I am trying to add in the formula select "LastRow" but can't get it work

Formula below works perfect look value in the C9

Code:
`````` Sub FillArrayFormula()

Dim LastRow As Long
LastRow = Cells(Rows.Count, "DJ").End(xlUp).Row + 1

Range("DJ" & LastRow).FormulaArray = "=CHOOSE(MATCH(MATCH([COLOR=#ff0000][B]\$C9[/B][/COLOR]&"""",RIGHT(\$X\$7:\$Z\$7),0),MATCH(SMALL(LEFT(\$X\$3:\$Z\$3,FIND(""/"",\$X\$3:\$Z\$3)-1)*1,{1,2,3}),LEFT(\$X\$3:\$Z\$3,FIND(""/"",\$X\$3:\$Z\$3)-1)*1,0),0),""L"",""M"",""H"")"
Range("DJ" & LastRow) = Range("DJ" & LastRow).Value

End Sub``````

I want look value in the C & LastRow. i try to modified the formula as shown below but does not result. Is it possible to do it, as I want?

Code:
`````` Sub FillArrayFormula_1()

Dim LastRow As Long
LastRow = Cells(Rows.Count, "DJ").End(xlUp).Row + 1

Range("DJ" & LastRow).FormulaArray = "=CHOOSE(MATCH(MATCH[COLOR=#000000]([/COLOR][COLOR=#ff0000][B]""C"" & LastRow[/B][/COLOR] &"""",RIGHT(\$X\$7:\$Z\$7),0),MATCH(SMALL(LEFT(\$X\$3:\$Z\$3,FIND(""/"",\$X\$3:\$Z\$3)-1)*1,{1,2,3}),LEFT(\$X\$3:\$Z\$3,FIND(""/"",\$X\$3:\$Z\$3)-1)*1,0),0),""L"",""M"",""H"")"
Range("DJ" & LastRow) = Range("DJ" & LastRow).Value

End Sub``````

Please need help if it could be modified or other way possible to use the formula, as I need it.

Thank you all
Excel 2000
Regards,
Moti

### Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

#### MARK858

##### MrExcel MVP
Untested but maybe...

Code:
``Range("DJ" & LastRow).FormulaArray = "=CHOOSE(MATCH(MATCH(\$C" & LastRow & "&"""",RIGHT(\$X\$7:\$Z\$7),0),MATCH(SMALL(LEFT(\$X\$3:\$Z\$3,FIND(""/"",\$X\$3:\$Z\$3)-1)*1,{1,2,3}),LEFT(\$X\$3:\$Z\$3,FIND(""/"",\$X\$3:\$Z\$3)-1)*1,0),0),""L"",""M"",""H"")"``

#### motilulla

##### Well-known Member
Untested but maybe...

Code:
``Range("DJ" & LastRow).FormulaArray = "=CHOOSE(MATCH(MATCH(\$C" & LastRow & "&"""",RIGHT(\$X\$7:\$Z\$7),0),MATCH(SMALL(LEFT(\$X\$3:\$Z\$3,FIND(""/"",\$X\$3:\$Z\$3)-1)*1,{1,2,3}),LEFT(\$X\$3:\$Z\$3,FIND(""/"",\$X\$3:\$Z\$3)-1)*1,0),0),""L"",""M"",""H"")"``
MARK858 , Your formula is giving a perfect result as request.

Have a nice day.

Kind Regards,
Moti

Replies
1
Views
179
Replies
6
Views
82
Replies
1
Views
48
Replies
3
Views
141
Replies
1
Views
185

1,136,327
Messages
5,675,128
Members
419,551
Latest member
thangxpm

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back