Code to replace formula

ExcelRoy

Well-known Member
Joined
Oct 2, 2006
Messages
2,388
Hi all,

I have the following formula that searches to find the latest row of data

Column C is the date
Column F is the job ref
Column G is the article ref

IF(AND(MAX(($C$12:$C$10023*($F$12:$F$10023=F322)*($G$12:$G$10023=G322)))=C322,C322<>""),"Latest","")

I have this on a long list and have to drag down the formula to 7000, plus rows

Is there a way to replicate this as code as to not slow up the sheet when typing?

Many thanks
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
5,676
Office Version
2019
Platform
Windows
If you are trying to find the last row in the column C, then the following code will work

Code:
Sub FindLast()
Dim lr as long
lr = Range("C" & rows.count).end(xlup).row
Msgbox ("Last Row is " & lr)
End Sub
 

ExcelRoy

Well-known Member
Joined
Oct 2, 2006
Messages
2,388
Hi Alansidman,

Apologies here but I may have mislead you with my requirements

The formula looks for the last entry for each job ref and shows this row by "Latest"

there may be many different entries with the same job refence but would like to see the latest entry as a quick reference

Thanks
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
45,120
Office Version
365
Platform
Windows
Before moving to code, you could try a formula like this. For me, it is about 5 times faster than your existing formula.
I have assumed that the formula quoted actually starts in row 12 with references to F12, G12 and C12
If that is so, you could try this in row 12 instead and copy down.

=IF(COUNTIFS(F12:F$10023,F12,G12:G$10023,G12)=1,"Latest","")
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
45,120
Office Version
365
Platform
Windows
You are very welcome. Thanks for letting us know.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,020
Messages
5,484,222
Members
407,435
Latest member
scottsweigart1

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top