Hello,
I am looking for a code to find the name of a table that contains a specific cell value.
Let me explain, I have a table that lists certain cell values. These values also occur in other tables in another worksheet. In my first table I want to add the table names of the tables in the other worksheet that contain these cell values.
So far I've gotten this far:
Function CloneName(FindString As String)
Dim Rng As Range
Dim Clone As String
If Trim(FindString) <> "" Then
With Sheets("Clones")
[FONT="]Set Rng = .Find(FindString)[/FONT]
If Not Rng Is Nothing Then
Clone = Rng.ListObject.Name
Else
Clone = ""
[FONT="]End If[/FONT]
[FONT="]End With[/FONT]
[FONT="]End If[/FONT]
CloneName = Clone
End Function
Unfortunately something in this code doesn't work and I can't figure out what. The .Find part works, because for those values that don't occur in the other worksheet I get a blank as I should. So I guess I'm doing something wrong in the ListObject statement, but however I rephrase I can't get it to work.
Any help would be thoroughly appreciated. I hope I was clear in what I'm looking for.
I am looking for a code to find the name of a table that contains a specific cell value.
Let me explain, I have a table that lists certain cell values. These values also occur in other tables in another worksheet. In my first table I want to add the table names of the tables in the other worksheet that contain these cell values.
So far I've gotten this far:
Function CloneName(FindString As String)
Dim Rng As Range
Dim Clone As String
If Trim(FindString) <> "" Then
With Sheets("Clones")
[FONT="]Set Rng = .Find(FindString)[/FONT]
If Not Rng Is Nothing Then
Clone = Rng.ListObject.Name
Else
Clone = ""
[FONT="]End If[/FONT]
[FONT="]End With[/FONT]
[FONT="]End If[/FONT]
CloneName = Clone
End Function
Unfortunately something in this code doesn't work and I can't figure out what. The .Find part works, because for those values that don't occur in the other worksheet I get a blank as I should. So I guess I'm doing something wrong in the ListObject statement, but however I rephrase I can't get it to work.
Any help would be thoroughly appreciated. I hope I was clear in what I'm looking for.