VLOOKUP, but causes result to stay permanently

mharper90

Board Regular
Joined
May 28, 2013
Messages
117
Office Version
  1. 365
Platform
  1. MacOS
Perhaps this is wishful thinking, but I'm looking for something that retrieves data similarly to a VLOOKUP function, but the resulting value would then become permanent.

My example:

I have a list of names on ws2, and an identical list of names on ws1, plus some extra outliers on ws1 that will never be on ws2. I want to use the name in column A on ws2, to find the matching name in column B of ws1, and then return particular values from the matching row on ws1 to the same row on ws2, but I want to decide which cells go where (such as ws1 column E would go to ws2 column C). I understand how to do this with VLOOKUP, but I only want this to happen on command, with a macro. So I don't want every change to ws1 to automatically update on ws2 as it would with a VLOOKUP. I just want it to update when and if the macro is run. I'd want this to run for every name in the list on ws2.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi there.

You could record a macro creating the vlookups in whatever cells you want the results, then finally select all the cells, copy then paster special... values. This will do the lookup but then replace the formulas with just the values.

Hope this helps.
 
Upvote 0
It's a bit clumsy perhaps, but a starting point for you if nothing else;

Code:
Sub CopyAcross()

Application.ScreenUpdating = False

Sheets("ws2").Select
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For x = 2 To LastRow
    NameToFind = Cells(x, "A").Value

    Sheets("ws1").Select
    Set SearchRange = Range("B1", Range("B" & Rows.Count).End(xlUp))
    Set findrow = SearchRange.Find(NameToFind, LookIn:=xlValues, lookat:=xlWhole)
    
    If Not findrow Is Nothing Then
        
        Sheets("ws2").Cells(x, "B").Value = Cells(findrow.Row, "D").Value
        Sheets("ws2").Cells(x, "C").Value = Cells(findrow.Row, "C").Value
    
    End If

    Sheets("ws2").Select

Next x

Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,922
Messages
6,122,281
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top