ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find Last duplicate value in Column A (https://www.excelbanter.com/excel-programming/382749-find-last-duplicate-value-column.html)

[email protected]

Find Last duplicate value in Column A
 
How do I find last duplicate value in Column A and put it in a cell
B1?

Appreciate all help


Tom Ogilvy

Find Last duplicate value in Column A
 
Sub FindLastDuplicate()
dim lastrow = cells(rows.count,1).End(xlup).row
for i = lastrow to 2 step -1
if application.countif(Range("A:A"),cells(i,1)) 1 Then
Range("B1").Value = cells(i,1)
exit sub
end if
Next
End Sub

Would be a code approach. Are you looking for a formula instead?

--
Regards,
Tom Ogilvy


" wrote:

How do I find last duplicate value in Column A and put it in a cell
B1?

Appreciate all help



[email protected]

Find Last duplicate value in Column A
 
This works perfect! Thank you for your help!

On Feb 7, 11:37 am, Tom Ogilvy
wrote:
Sub FindLastDuplicate()
dim lastrow = cells(rows.count,1).End(xlup).row
for i = lastrow to 2 step -1
if application.countif(Range("A:A"),cells(i,1)) 1 Then
Range("B1").Value = cells(i,1)
exit sub
end if
Next
End Sub

Would be a code approach. Are you looking for a formula instead?

--
Regards,
Tom Ogilvy



" wrote:
How do I find last duplicate value in Column A and put it in a cell
B1?


Appreciate all help- Hide quoted text -


- Show quoted text -




[email protected]

Find Last duplicate value in Column A
 
Hi Tom,

What if I wanted to find the last duplicate value the following way:

IF this is the data,

A B

1: day1 Jan
2: day1 Feb
3: day1 Mar
4: day2 Apr
5: day2 May
6: day3 June
7: day3 July
8: day5 Aug
9: day5 Sep

How could I display the last value of each type and the respective
column B data (in a textbox):

day1 Mar
day2 May
day3 July
day5 Sep

Thanks!

On Feb 7, 11:53 am, wrote:
This works perfect! Thank you for your help!

On Feb 7, 11:37 am, Tom Ogilvy
wrote:



Sub FindLastDuplicate()
dim lastrow = cells(rows.count,1).End(xlup).row
for i = lastrow to 2 step -1
if application.countif(Range("A:A"),cells(i,1)) 1 Then
Range("B1").Value = cells(i,1)
exit sub
end if
Next
End Sub


Would be a code approach. Are you looking for a formula instead?


--
Regards,
Tom Ogilvy


" wrote:
How do I find last duplicate value in Column A and put it in a cell
B1?


Appreciate all help- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -





All times are GMT +1. The time now is 01:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com