Hi Gulshan,
Below are two code snippets that you can use to build the type of formula you are looking for.
Sub Pull(DirNam, FilNam, SheetNam, CellAdd, TarCell)
'This places the formula in the cell of your choice
ConRange = SheetNam &; "'!" &; CellAdd
ConNam = DirNam &; "[ &; FilNam & ]"
Range(TarCell).Formula = "='" &; ConNam & ConRange
End Sub
Sub test()
'This gets the Directory Name, File Name, Sheet Name, Source cell and Target Cell from the Master file.
DirNam = Range("C3") 'E:AnalystKPIs & Reporting2010Faster line detailed reportingTransportCosts
FilNam = Range("D3") 'C2_C3_Nov2010.xlsm
SheetNam = Range("E3") 'ByLocation
CellAdd = Range("F3") 'C5
TarCell = Range("G3") 'K36
Call Pull(DirNam, FilNam, SheetNam, CellAdd, TarCell)
End Sub
Try these out and then change them to suit, you will note that I have not specified the type of variable (very bad practice)