Code to replace formula

ExcelRoy

Well-known Member
Joined
Oct 2, 2006
Messages
2,395
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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
5,695
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,395
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,261
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,261
Office Version
365
Platform
Windows
You are very welcome. Thanks for letting us know.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,782
Messages
5,488,850
Members
407,658
Latest member
Arias610

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top