PDA

View Full Version : Vlookup problem



mugcy
05-05-2009, 11:06 PM
HI, I have a prob with the following


I have a workbook(cash rec.xls) with 60 different WS for each store.This file is saved in the "S:\Cash\Banking Rec 2009" folder. Each WS has a different sheet name i.e

sheet1(abc 01)
sheet2(def 02)
sheet3(ghi 03)



I have setup the following VLOOKUP statement using a macro on the first sheet.

Range("G4").Select
ActiveSheet.Paste
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-6],'S:\Cash\Banking Rec 2009\Store Cash Recs\[abc.xls]Period 6'!R5C2:R43C11,7,0)"
Range("G13").Select
ActiveSheet.Paste
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-6],'S:\Cash\Banking Rec 2009\Store Cash Recs\[abc.xls]Period 6'!R5C2:R43C11,7,0)"
Range("G23").Select
ActiveSheet.Paste
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-6],'S:\Cash\Banking Rec 2009\Store Cash Recs\[abc.xls]Period 6'!R5C2:R43C11,7,0)"
Range("G33").Select
ActiveSheet.Paste
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-6],'S:\Cash\Banking Rec 2009\Store Cash Recs\[abc.xls]Period 6'!R5C2:R43C11,7,0)"
Range("G34").Select

The prob I have is to get to run a macro (lets say from sheet2), so that it will automatically replace the .xls file in the VLOOKUP statement with "def" and so on for other sheets without direct input


I'm Very new to VBA. Can some one please help???