MKnightsS17
Board Regular
- Joined
- Sep 25, 2009
- Messages
- 106
Hi all,
is there a way to perform an action in VBA that works similarly to the INDEX function but interfaces between workbooks.
To give an idea of what I mean, this is the relevant part of a code I have used to index between two worksheets in the same workbook, earlier in the macro:
Where Ps is a worksheet and JobSummary is a worksheet in the same workbook, and highlighted is the formula that works in the relevant cells.
The only method I can think of (please bear with me) involves creating a temporary sheet in the same workbook as the (hypothetical) JobSummay sheet; copying the relevant table from the (hypothetical) Ps sheet into it; putting the formula into this temporary sheet using this method i have above; then copying the relevant new indexed column back across to the other workbook; Then closing the temporary sheet. (phew!)
But with the amount of data im using this is both messy and would add alot of runtime to the macro.
Any ideas?
thanks
is there a way to perform an action in VBA that works similarly to the INDEX function but interfaces between workbooks.
To give an idea of what I mean, this is the relevant part of a code I have used to index between two worksheets in the same workbook, earlier in the macro:
Code:
Dim Ps As Worksheet
Set Ps = Worksheets("PersonSummary")
LcPs = Ps.Range("A1").SpecialCells(xlCellTypeLastCell).Column
LrPs = Ps.UsedRange.Find("*", Searchdirection:=xlPrevious, searchorder:=xlByRows).Row
For n = 2 To LrPs
Ps.Cells(n, LcPs + 1).Formula = "[COLOR=red]=INDEX(JobSummary!B:B,MATCH(C" & n & ",JobSummary!C:C,0))[/COLOR]"
Next n
Where Ps is a worksheet and JobSummary is a worksheet in the same workbook, and highlighted is the formula that works in the relevant cells.
The only method I can think of (please bear with me) involves creating a temporary sheet in the same workbook as the (hypothetical) JobSummay sheet; copying the relevant table from the (hypothetical) Ps sheet into it; putting the formula into this temporary sheet using this method i have above; then copying the relevant new indexed column back across to the other workbook; Then closing the temporary sheet. (phew!)
But with the amount of data im using this is both messy and would add alot of runtime to the macro.
Any ideas?
thanks