Hi,
i recorded a vlook up for 3 different columns and applied it to new work book and it kind of works.. what part of the code do i need to change in order to make it to work for any amount of data? the original workbook had 800 lines the new work book has 2000 lines but the macro only applied it to 800, my guess is has something to do with the range. Also if the data is less than 800 it'll work but will just put N/A on blanks lines...
[code/]
Sub vlookup()
'
' vlookup Macro
'
'
Range("E2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'Vendor Policies'!C[-4]:C[-1],4,FALSE)"
Selection.AutoFill Destination:=Range("E2:E831")
Range("E2:E831").Select
ActiveWindow.LargeScroll ToRight:=1
Range("R2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-14],'Vendor Policies'!C[-17]:C[-6],12,FALSE)"
Selection.AutoFill Destination:=Range("R2:R831")
Range("R2:R831").Select
Range("S2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-15],'Vendor Policies'!C[-18]:C[2],21,FALSE)"
Selection.AutoFill Destination:=Range("S2:S831")
Range("S2:S831").Select
Columns("R:S").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
[/code]
i recorded a vlook up for 3 different columns and applied it to new work book and it kind of works.. what part of the code do i need to change in order to make it to work for any amount of data? the original workbook had 800 lines the new work book has 2000 lines but the macro only applied it to 800, my guess is has something to do with the range. Also if the data is less than 800 it'll work but will just put N/A on blanks lines...
[code/]
Sub vlookup()
'
' vlookup Macro
'
'
Range("E2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'Vendor Policies'!C[-4]:C[-1],4,FALSE)"
Selection.AutoFill Destination:=Range("E2:E831")
Range("E2:E831").Select
ActiveWindow.LargeScroll ToRight:=1
Range("R2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-14],'Vendor Policies'!C[-17]:C[-6],12,FALSE)"
Selection.AutoFill Destination:=Range("R2:R831")
Range("R2:R831").Select
Range("S2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-15],'Vendor Policies'!C[-18]:C[2],21,FALSE)"
Selection.AutoFill Destination:=Range("S2:S831")
Range("S2:S831").Select
Columns("R:S").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
[/code]