Vba Vlookup Problem

Joined
Jan 28, 2009
Messages
1
Reaction score
0
This code i have does a vlookup if something is put in the cell, (more specifically, it actually puts the vlookup formula IN the cell) and then when i fill in a different cell, it copies the whole row, dumps it in the appropriate sheet, and removes the original row. Now when it copies the row, it puts the vlookup formula in the other sheet and I would really rather have just the VALUE that the vlookup finds.
I think that I need to have the code PERFORM a vlookup instead of writing one in the cell rather than somehow do a 'paste special' to only get the values copies instead of the whole formula. What should I do?

Private Sub Worksheet_Change(ByVal Target As Range)
' if changes are made in column D
If Target.Column = 4 And Target.Count > 0 Then
If Len(Trim(Target.Text)) <> 0 Then
Application.EnableEvents = False
Target.Offset(0, 1).FormulaR1C1 = _
"=VLOOKUP(RC4,Outlets!R1C1:R16000C4,2,FALSE)"
Target.Offset(0, 2).FormulaR1C1 = _
"=VLOOKUP(RC4,Outlets!R1C1:R16000C4,3,FALSE)"
Target.Offset(0, 3).FormulaR1C1 = _
"=VLOOKUP(RC4,Outlets!R1C1:R16000C4,4,FALSE)"
Application.EnableEvents = True
End If
ElseIf Target.Column = 2 And Target.Count = 1 Then
' process changes made in column B or adjust as appropriate
Select Case Range("B65536").End(xlUp).Value
Case 39814 To 39844
Application.EnableEvents = False
Last_Row_Sheet2 = Sheets("Jan").Range("B65536").End(xlUp).Row
Range("B" & Target.Row).EntireRow.Copy Sheets("Jan").Cells(Last_Row_Sheet2 + 1, 1)
Range("B" & Target.Row).EntireRow.Delete
Application.EnableEvents = True

And so on...
 
Back
Top