How can apply "LastRow" in the formula

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
1,924
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
Joined
Nov 12, 2010
Messages
14,140
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
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
Joined
Feb 13, 2008
Messages
1,924
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.

Thank you for your help.

Have a nice day.

Kind Regards,
Moti :)
 

Forum statistics

Threads
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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Top