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]
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!