Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy formula

Status
Not open for further replies.

iken

Mechanical
May 13, 2003
151
Hi all,

Just wondering if anybody knows an easy way of copying formula across a sheet, which has links to other sheets in the workbook.

What I have is a summry page, which links sub totals from ohter sheets. What I would like to do is copy this to the cell next door, but have the sheet reference change, i.e cell A1 = subtotal of cell A2 from sheet2 - then copy this to cell B1 = subtotal of cell A2 from sheet3.

Any ideas of how (or if) this can be done.

At present I have to manullay change the sheet reference which can be very time consuming if there are 30-40 sheets.

Thanks in advance
 
Replies continue below

Recommended for you

If this is repetitive, you can create a macro.

TTFN



 
There is a way to reference sheet names indirectly. I can't remember how exactly, it needed a bit of lateral thinking.



Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Let's try this again . . .

You can use indirect addressing, but you'll need to create another row to generate the sheet names. Assuming that the sheets retain Excel's default naming scheme, write the first formula in cell A2 and copy it across as required. The column(A1) function will take the drudgery out of indexing the sheet number. Then write the second formula in cell A3 and copy this as required. The "$A$2" part of this formula is, of course, the common cell address for the subtotals in the sheets, so absolute referencing of at least the column letter is necessary here. I'd avoid putting either formula in the row that the column() function in the first formula refers to, just to avoid possible circular reference issues.


="Sheet"&TEXT(COLUMN(A1),"0")&"!"

=INDIRECT(A2&"$A$2")


A similar technique can be used to grab data from several completely separate workbooks, although I think all the workbooks would need to be open.


Norm
 
Note that the "A1" COLUMN(A1) in the first formula will result in the first result (in cell A3) being read from Sheet1, and is appropriate if the summary is being written in the last sheet of the workbook rather than the first. If your summary is on Sheet1 and the subtotal data sheets start at Sheet2, cell A2 should instead read in part COLUMN(B1); or COLUMN(C1) if the subtotals start in Sheet3, etc.

Norm
 
Cheers NormPeterson. This works a treat.
 
Just to add to NormPaterson's.

I have a formula (from a previous question of mine) that calls up the worksheet name. This being:

=MID(CELL("FILENAME",A5),FIND("]",CELL("FILENAME",A5))+1,256)

However this only refers to the current worksheet name, is there any way this can be put on say Sheet1, to reference the name of Sheet2, Sheet3 etc. This would elimate (in around about ways) of the first formula in Norms post, and would enable the renaiming of worksheets?

Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor