Share via

replace string with vlookup value

Anonymous
2016-09-07T15:14:23+00:00

I need to replace a string of values with results from a vlookup.

I need a text box that asks the user what column would they like to replace. 

Once the user enters the column, start at row 5 to the last used row in that column.

The lookup should compare the existing text in named range "ISO" and return the value from the second column replacing the existing value

Example: If column V, it would be something like VLOOKUP(V5,ISO,2,FALSE) )

If a helper column is needed, ZZ can be used temporarily but must be cleared after running.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2016-09-07T15:29:38+00:00

Sub Test()

    Dim r As Range

    Set r = Application.InputBox("Select a cell in the column", Type:=8)

    Set r = Range(Cells(5, r.Column), Cells(Rows.Count, r.Column).End(xlUp))

    With Range(Cells(5, "ZZ"), Cells(Cells(Rows.Count, r.Column).End(xlUp).Row, "ZZ"))

        .Formula = "=VLOOKUP(" & r.Cells(1).Address(False, False) & ",ISO,2,False)"

        r.Value = .Value

        .Clear

    End With

End Sub

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2016-09-07T16:28:05+00:00

    I have a stack of Krystal IOUs that I will add this one to ;-)

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-09-07T16:15:48+00:00

    Thanks!

    When I make my first million..... 

    I'm buying you a Krystal WITH cheese!

    Was this answer helpful?

    0 comments No comments