Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / September 2007

Tip: Looking for answers? Try searching our database.

Keep formula except for tab number

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Birney - 27 Sep 2007 14:11 GMT
I'd like to copy a tab to a new tab, and then have it read information
from the previous tab.  Example:  ='4'!B112   Where on tab 5 it is
reading from tab 4, cell B112.    I'd like to change the 4 to be "the
page before" so I don't have to change the 4 to 5 and 6, .... on every
tab.  Is there a command for that?
Gord Dibben - 27 Sep 2007 15:37 GMT
Mike

If you're willing to use a User Defined Function.......

Function PrevSheet(rg As Range)
   n = Application.Caller.Parent.Index
   If n = 1 Then
       PrevSheet = CVErr(xlErrRef)
   ElseIf TypeName(Sheets(n - 1)) = "Chart" Then
       PrevSheet = CVErr(xlErrNA)
   Else
       PrevSheet = Sheets(n - 1).Range(rg.Address).Value
   End If
End Function

Say you have 20 sheets,  sheet1 through sheet20...........sheet names don't
matter.

Select second sheet and SHIFT + Click last sheet

In active sheet B1 enter =PrevSheet(A1)

Ungroup the sheets.

Each B1 will have the contents of the previous sheet's A1

Copy/paste the UDF above into a General Module in your workbook.

If not familiar with macros and VBA, visit David McRitchie's website on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and Insert>Module.  Paste the above code in there.  Save the
workbook and hit ALT + Q to return to your workbook.

Gord Dibben Excel MVP

>I'd like to copy a tab to a new tab, and then have it read information
>from the previous tab.  Example:  ='4'!B112   Where on tab 5 it is
>reading from tab 4, cell B112.    I'd like to change the 4 to be "the
>page before" so I don't have to change the 4 to 5 and 6, .... on every
>tab.  Is there a command for that?
Mike Birney - 27 Sep 2007 19:45 GMT
Gord,
Thank you!!!!
Mike

> Mike
>
[quoted text clipped - 47 lines]
>> page before" so I don't have to change the 4 to 5 and 6, .... on every
>> tab.  Is there a command for that?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.