Sub naming()
Range("A2", Range("A2").End(xlDown)).name = "Names"
End Sub
Sub MatchApplication()
Dim val As Variant, name As String
name = InputBox("Enter the name you wish to search for")
val = Application.Match(name, "Names", 0)
End Sub
Sub naming()
Range("A2", Range("A2").End(xlDown)).name = "Names"
End Sub
Sub MatchApplication()
Dim val As Variant, name As String
name = InputBox("Enter the name you wish to search for")
val = Application.Match(name, "Names", 0)
End Sub
Try
Please Login or Register to view this content.
_
...How to Cross-post politely...
..Wrap code by selecting the code and clicking the # or read this. Thank you.
That worked! Thank you! I am trying to use that match function value in an offset function to give me the values of the cells corresponding to a user entered name, however I am now getting an object defined error and am not quite sure why... Any thoughts?
Sub naming()
Range("A2", Range("A2").End(xlDown)).name = "Names"
End Sub
Sub MatchApplication()
Dim val As Variant, name As String, x As Variant
name = InputBox("Enter the name you wish to search for")
val = Application.Match(name, Range("Names"), 0)
If IsError(val) Then MsgBox "not found"
val.Offset(0, 1).value = x
MsgBox x
End Sub
I realize that val is equal to the location of a cell and is not the actual 'reference cell' that offset requires but I am not sure how to make the two relate together
The range that you have named "Name" is in a column.
val is the number of rows (relative to the Name) on which the entered name is found.
Range("Names").Cells(val, 1) is the cell that contains the entered name.
Range("Names").Cells(val, 2) is one cell to the right of that.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks