In Column A if cell 36 has "2015 Stores" then i need a code to identify this cell number.
This can be dynamic and the text can be present in any cell.
Thanks in advance.
In Column A if cell 36 has "2015 Stores" then i need a code to identify this cell number.
This can be dynamic and the text can be present in any cell.
Thanks in advance.
This will do if it's in column A & 2015 Stores is in B1
![]()
=IFERROR(ADDRESS(ROW(INDEX(A:A,MATCH(B1,A:A,0))),1),"?")
Try something like this...
You may change the FindValue in the red line if you are looking for some other text in col. A. The above code will give you the address of the cell in col. A which contains 2015 Stores in it.![]()
Sub FindCellNumber() Dim cell As Range Dim FindValue As String FindValue = "2015 Stores" Set cell = Range("A:A").Find(FindValue) If Not cell Is Nothing Then MsgBox cell.Address(0, 0) Else MsgBox FindValue & " is not found in Column A." End If End Sub
Moreover if you are interested in knowing the row number, you may change the message box to this...
Does this help?![]()
MsgBox cell.Row
Last edited by sktneer; 12-09-2014 at 03:11 AM.
Regards
sktneer
Treat people the way you want to be treated. Talk to people the way you want to be talked to.
Respect is earned NOT given.
It just dawned on me you asked for VBA code. I see sktneer has already given one solution
Here's another. It'll find it anywhere on worksheet 1
![]()
Option Explicit Sub FindAddress() Dim Ws As Worksheet Dim Col As Long Dim rRow As Long Dim String2Find As String Set Ws = ThisWorkbook.Sheets(1) String2Find = "2015 Stores" On Error Resume Next rRow = Ws.Rows().Find(What:=String2Find, LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByRows, searchdirection:=xlPrevious, _ MatchCase:=False, SearchFormat:=False).Row Col = Ws.Columns().Find(What:=String2Find, LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByColumns, searchdirection:=xlPrevious, _ MatchCase:=False, SearchFormat:=False).Column On Error GoTo 0 If Not rRow = 0 Or Not Col = 0 Then MsgBox String2Find & " Is In " & Ws.Cells(rRow, Col).Address Else MsgBox String2Find & " Not Found" End If End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks