Code to replace formula

ExcelRoy

Well-known Member
Joined
Oct 2, 2006
Messages
2,540
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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
 
Upvote 0
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
 
Upvote 0
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","")
 
Upvote 0
You are very welcome. Thanks for letting us know.
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

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
Back
Top