Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I have a spreadsheet that has many cells linked to other cells on the same
sheet From the links I want to know the row number of the reference. Eg: A1 value CAT A200 value CAT Cell A1 has the formula "=A200" Using Cell A1 information only I want to know row the row number it references , that is 200. How do i do this? |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
=MATCH(A1,A2:A400,0)+1
Assumes that there is only one instance of CAT HTH Peter "Emily" wrote: I have a spreadsheet that has many cells linked to other cells on the same sheet From the links I want to know the row number of the reference. Eg: A1 value CAT A200 value CAT Cell A1 has the formula "=A200" Using Cell A1 information only I want to know row the row number it references , that is 200. How do i do this? |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
it is likely that there will be many instances of the value the actual value
of that cell A1 returns is not of interest. "Billy Liddel" wrote: =MATCH(A1,A2:A400,0)+1 Assumes that there is only one instance of CAT HTH Peter "Emily" wrote: I have a spreadsheet that has many cells linked to other cells on the same sheet From the links I want to know the row number of the reference. Eg: A1 value CAT A200 value CAT Cell A1 has the formula "=A200" Using Cell A1 information only I want to know row the row number it references , that is 200. How do i do this? |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Emily
I'm not sure which row you want to find. and MATCH will not find a true value if the list is not sorted. Say you wanted to know how many values in the list are equal to A1, then use this function: =SUMPRODUCT(--(A2:A400=A1)) You can then use this User Defined Function (UDF) to find the row of the instance. For example my list contained three Cats. To find the row of the second cat in the list you will enter: =findrow(A1,A4:A400,2) To find the last row type: =findrow(A1,A4:A400) To make this work you have to copy the following code into a Visual Basic Module. Press ALT + F11, Insert Module then Paste the code into the module, close the module, FileClose and enter the formula in the worksheet. The code is between the Lines ' ================================================ Option Explicit Function FindRow(ByVal Ref As Range, Data As Range, Optional Instance As Long) As Long Dim c As Variant Dim row As Long Dim Counter As Long Select Case Instance Case Is = 0 ' or missing, find last row For Each c In Data If LCase(c) = LCase(Ref) Then row = c.row FindRow = row End If Next Case Is 0 ' find the row of the Nth instance For Each c In Data If LCase(c) = LCase(Ref) Then row = c.row Counter = Counter + 1 If Counter = Instance Then FindRow = row Exit Function End If End If Next End Select End Function ' ============================================ Hope this give you what you want. Peter "Emily" wrote: it is likely that there will be many instances of the value the actual value of that cell A1 returns is not of interest. "Billy Liddel" wrote: =MATCH(A1,A2:A400,0)+1 Assumes that there is only one instance of CAT HTH Peter "Emily" wrote: I have a spreadsheet that has many cells linked to other cells on the same sheet From the links I want to know the row number of the reference. Eg: A1 value CAT A200 value CAT Cell A1 has the formula "=A200" Using Cell A1 information only I want to know row the row number it references , that is 200. How do i do this? |
#5
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Sorry, i think I have not explained myself very well.
I want to return the row number of the cell referenced in the formulae on A1. So if the formula in A1 is =A200 200 would be returned. The spreadsheet may not have any llists in it and the reference could be to any cell on the spreadsheet. I could do cell('row",A200) or row(A200). but it means viewing the formulae working out at cell A1 contains a link to A200. I may as well type 200 in the cell. i have over 100 cells I need to do this for. I think if i could return the formulae as string I might get somewhere. Is this any clearer? thanks Emily "Billy Liddel" wrote: Emily I'm not sure which row you want to find. and MATCH will not find a true value if the list is not sorted. Say you wanted to know how many values in the list are equal to A1, then use this function: =SUMPRODUCT(--(A2:A400=A1)) You can then use this User Defined Function (UDF) to find the row of the instance. For example my list contained three Cats. To find the row of the second cat in the list you will enter: =findrow(A1,A4:A400,2) To find the last row type: =findrow(A1,A4:A400) To make this work you have to copy the following code into a Visual Basic Module. Press ALT + F11, Insert Module then Paste the code into the module, close the module, FileClose and enter the formula in the worksheet. The code is between the Lines ' ================================================ Option Explicit Function FindRow(ByVal Ref As Range, Data As Range, Optional Instance As Long) As Long Dim c As Variant Dim row As Long Dim Counter As Long Select Case Instance Case Is = 0 ' or missing, find last row For Each c In Data If LCase(c) = LCase(Ref) Then row = c.row FindRow = row End If Next Case Is 0 ' find the row of the Nth instance For Each c In Data If LCase(c) = LCase(Ref) Then row = c.row Counter = Counter + 1 If Counter = Instance Then FindRow = row Exit Function End If End If Next End Select End Function ' ============================================ Hope this give you what you want. Peter "Emily" wrote: it is likely that there will be many instances of the value the actual value of that cell A1 returns is not of interest. "Billy Liddel" wrote: =MATCH(A1,A2:A400,0)+1 Assumes that there is only one instance of CAT HTH Peter "Emily" wrote: I have a spreadsheet that has many cells linked to other cells on the same sheet From the links I want to know the row number of the reference. Eg: A1 value CAT A200 value CAT Cell A1 has the formula "=A200" Using Cell A1 information only I want to know row the row number it references , that is 200. How do i do this? |
#6
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Emily wrote:
Sorry, i think I have not explained myself very well. I want to return the row number of the cell referenced in the formulae on A1. So if the formula in A1 is =A200 200 would be returned. The spreadsheet may not have any llists in it and the reference could be to any cell on the spreadsheet. I could do cell('row",A200) or row(A200). but it means viewing the formulae working out at cell A1 contains a link to A200. I may as well type 200 in the cell. i have over 100 cells I need to do this for. I think if i could return the formulae as string I might get somewhere. Is this any clearer? thanks Emily Try this: http://www.vbaexpress.com/kb/getarticle.php?kb_id=62 |
#7
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
You can easily inspect a formula by pressing (Ctrl + `) the ` is on the Esc
Key. This toggles the view so that formulas are displayed/not diplayed. If you don't mind the UDF method the following will work on a simple formula: Function GetRefRow(ByVal Ref As Range) As Variant Dim str As String, Temp As String, row As Variant Dim i As Long If Ref.HasFormula Then str = Ref.Formula For i = Len(str) To 1 Step -1 row = Mid(str, i, 1) If IsNumeric(row) Then Temp = row & Temp End If GetRefRow = Temp Next i Else: Temp = "No formula" End If End Function Carry out the instructions as mentioned before. Tick Yes if this helps. Peter "Emily" wrote: Sorry, i think I have not explained myself very well. I want to return the row number of the cell referenced in the formulae on A1. So if the formula in A1 is =A200 200 would be returned. The spreadsheet may not have any llists in it and the reference could be to any cell on the spreadsheet. I could do cell('row",A200) or row(A200). but it means viewing the formulae working out at cell A1 contains a link to A200. I may as well type 200 in the cell. i have over 100 cells I need to do this for. I think if i could return the formulae as string I might get somewhere. Is this any clearer? thanks Emily "Billy Liddel" wrote: Emily I'm not sure which row you want to find. and MATCH will not find a true value if the list is not sorted. Say you wanted to know how many values in the list are equal to A1, then use this function: =SUMPRODUCT(--(A2:A400=A1)) You can then use this User Defined Function (UDF) to find the row of the instance. For example my list contained three Cats. To find the row of the second cat in the list you will enter: =findrow(A1,A4:A400,2) To find the last row type: =findrow(A1,A4:A400) To make this work you have to copy the following code into a Visual Basic Module. Press ALT + F11, Insert Module then Paste the code into the module, close the module, FileClose and enter the formula in the worksheet. The code is between the Lines ' ================================================ Option Explicit Function FindRow(ByVal Ref As Range, Data As Range, Optional Instance As Long) As Long Dim c As Variant Dim row As Long Dim Counter As Long Select Case Instance Case Is = 0 ' or missing, find last row For Each c In Data If LCase(c) = LCase(Ref) Then row = c.row FindRow = row End If Next Case Is 0 ' find the row of the Nth instance For Each c In Data If LCase(c) = LCase(Ref) Then row = c.row Counter = Counter + 1 If Counter = Instance Then FindRow = row Exit Function End If End If Next End Select End Function ' ============================================ Hope this give you what you want. Peter "Emily" wrote: it is likely that there will be many instances of the value the actual value of that cell A1 returns is not of interest. "Billy Liddel" wrote: =MATCH(A1,A2:A400,0)+1 Assumes that there is only one instance of CAT HTH Peter "Emily" wrote: I have a spreadsheet that has many cells linked to other cells on the same sheet From the links I want to know the row number of the reference. Eg: A1 value CAT A200 value CAT Cell A1 has the formula "=A200" Using Cell A1 information only I want to know row the row number it references , that is 200. How do i do this? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
referenced cells | Excel Discussion (Misc queries) | |||
can chart title be linked to variable cell address? | Excel Discussion (Misc queries) | |||
Linked Cells Staying With Cells Once Linked Workbook Update. | Excel Worksheet Functions | |||
Address for Linked Files in Formula | Excel Worksheet Functions | |||
Missing linked file - can still be referenced but can't find it! | Excel Worksheet Functions |