Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default i = row number of last occurance of duplicate string Column A


In the code, trying to assign the row number this formula returns to i.
=LOOKUP(2,1/(A1:A20="abc"),ROW(A1:A20)) = 15 (on the sheet Array Enter)

Errors out with "OneRng" in this line highlighted in blue (OneRng = "abc")
Code compiles, but with "expanded" spaces?? Then errors when run.

Sub SomeRangeA()
Dim OneRng As Range
Dim i As Long, ii As Long

Set OneRng = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
i = Application.WorksheetFunction.Lookup(2, 1 / (OneRng = "abc"), Row(OneRng))

End Sub

Thanks,
Howard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default i = row number of last occurance of duplicate string Column A

Hi Howard,

Am Tue, 4 Nov 2014 04:14:39 -0800 (PST) schrieb L. Howard:

Set OneRng = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
i = Application.WorksheetFunction.Lookup(2, 1 / (OneRng = "abc"), Row(OneRng))


try:
Sub SomeRangeA()
Dim lRow As Long
Dim i As Long

lRow = Cells(Rows.Count, "A").End(xlUp).Row
i = Evaluate("=Lookup(2,1/(A2:A" & lRow & " = ""abc""), Row(A2:A" & lRow & "))")
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default i = row number of last occurance of duplicate string Column A

On Tuesday, November 4, 2014 4:59:59 AM UTC-8, Claus Busch wrote:
Hi Howard,

Am Tue, 4 Nov 2014 04:14:39 -0800 (PST) schrieb L. Howard:

Set OneRng = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
i = Application.WorksheetFunction.Lookup(2, 1 / (OneRng = "abc"), Row(OneRng))


try:
Sub SomeRangeA()
Dim lRow As Long
Dim i As Long

lRow = Cells(Rows.Count, "A").End(xlUp).Row
i = Evaluate("=Lookup(2,1/(A2:A" & lRow & " = ""abc""), Row(A2:A" & lRow & "))")
End Sub


Regards
Claus B.
--



Thanks Claus, works well.

Is there a short answer as to why Application.WorksheetFunction.... does not work?

Howard
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default i = row number of last occurance of duplicate string Column A

Hi Howard,

Am Tue, 4 Nov 2014 06:44:41 -0800 (PST) schrieb L. Howard:

Is there a short answer as to why Application.WorksheetFunction.... does not work?


I don't know. If the syntax is correct I get a Type Mismatch.

But you can also try it with MATCH:

Sub Test()
Dim i As Long, LRow As Long

LRow = Cells(Rows.Count, 1).End(xlUp).Row
With WorksheetFunction
i = .Match("""abc""", Range("A1:A" & LRow), -1)
End With
MsgBox i
End Sub



Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default i = row number of last occurance of duplicate string Column A

On Tuesday, November 4, 2014 7:07:51 AM UTC-8, Claus Busch wrote:
Hi Howard,

Am Tue, 4 Nov 2014 06:44:41 -0800 (PST) schrieb L. Howard:

Is there a short answer as to why Application.WorksheetFunction.... does not work?


I don't know. If the syntax is correct I get a Type Mismatch.

But you can also try it with MATCH:

Sub Test()
Dim i As Long, LRow As Long

LRow = Cells(Rows.Count, 1).End(xlUp).Row
With WorksheetFunction
i = .Match("""abc""", Range("A1:A" & LRow), -1)
End With
MsgBox i
End Sub



Regards
Claus B.



Okay, appreciate the info.

Your first suggestion works quite well and I am using it.

Thanks again.

Regards,
Howard
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
duplicate occurance, assigning an ordinal value mcheng Excel Worksheet Functions 14 June 14th 07 05:21 PM
Count occurance of largest duplicate number in a single column ran catpro New Users to Excel 5 January 21st 07 05:10 PM
Occurance Number Within a String JohnnyBGood Excel Discussion (Misc queries) 4 December 20th 05 04:59 PM
How do I select the first occurance of a number in a column Corner920 Excel Programming 2 July 18th 05 07:26 AM
Locating Cell Number of first occurance of data in Column genzu Excel Programming 6 June 16th 04 03:44 AM


All times are GMT +1. The time now is 08:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"