Excel VLOOKUP replace found value to jump on next value

stefutz

New Member
Joined
Jan 15, 2018
Messages
3
Code:
[COLOR=#242729][FONT=Consolas]Public Function replacefoundvalue(aNumber)[/FONT][/COLOR]<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">
Dim rng As Range

Set rng = Sheet1.Range("A2:A103")

    If Application.WorksheetFunction.CountIf(rng, aNumber) > 0 Then
        test = Application.WorksheetFunction.VLookup(aNumber, Sheet1.Range("A2:B103"), 2, False) ' this is working
        test.Copy
        test.PasteSpecial xlPasteValues
        Sheets("Sheet1").Columns("A").Rows(Application.WorksheetFunction.Match(aNumber, rng, 0)).Value = ""
    Else
        MsgBox aNumber & " does not exist in range " & rng.Address
    End If</code>[COLOR=#242729][FONT=Consolas]End Function
[/FONT][/COLOR]
Hello!
I'm trying to find a value using vlookup ( and that working ) after found it, i want to copy and replace the formula with the value( in this way removing the found value won't affect that cell) then replace the found value with "".
Any ideea what's wrong ?
Thank you verry much!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,214,971
Messages
6,122,520
Members
449,088
Latest member
RandomExceller01

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