Thread: Vlookup
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
STEVEB STEVEB is offline
external usenet poster
 
Posts: 1
Default Vlookup

Hello,

I am trying to have a MACRO automatically do a VLOOKUP and paste the
results into my spreadsheet. I have input the formula manually and it
works, so I know the file names and ranges are correct.

Column A is the data to lookup and Column B is where I want the VLOOKUP
to enter the results.

My futile effort for a code is below:

Worksheets("Sheet 1").Activate

Set CurrentCell = Range("A2")
Do While Not IsEmpty(CurrentCell)
Set CurrentCell = CurrentCell.Offset(0, 1)
Set NextCell = CurrentCell.Offset(1, 0)

Range("B2").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1], '[FILE
NAME.xls]Sheet1'!$A$2:$B$1147,1,FALSE)"
CurrentCell.Copy
Selection.PasteSpecial Paste:=x1Values
Application.CutCopyMode = False
Set CurrentCell = NextCell

Loop

Next


End Sub


I Get a Run-time error 1004 - Application Defined or object defined
error.

Does anyone have any suggestions? I know this is probably an easy fix
but it is driving me crazy.

Thanks



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/