Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Scott S
 
Posts: n/a
Default How do I pull data from a previous worksheet?

I have a file with 31 worksheets, one for each day of my accounting period.
Each worksheet is divided into 2 parts, daily and period to date. I am
trying to calculate the rolling totals each day. I can do it, but reentering
the manipulated formulas for each day is very time consuming. Isn't there a
way to pull data from a previous worksheet by using a command "previous"? I
could've sworn I've seen it somewhere before.


  #2   Report Post  
Gord Dibben
 
Posts: n/a
Default

Scott

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

Function PrevSheet(rg As Range)
'Enter =PrevSheet(B1) on sheet2 and you'll get B1 from sheet1.
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 31 sheets, sheet1 through sheet31.

Select sheet2 and SHIFT + Click sheet31

In 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 InsertModule. Paste the above code in there. Save the
workbook and hit ALT + Q to return to your workbook.


Gord Dibben Excel MVP


On Sun, 27 Feb 2005 15:55:03 -0800, "Scott S" <Scott
wrote:

I have a file with 31 worksheets, one for each day of my accounting period.
Each worksheet is divided into 2 parts, daily and period to date. I am
trying to calculate the rolling totals each day. I can do it, but reentering
the manipulated formulas for each day is very time consuming. Isn't there a
way to pull data from a previous worksheet by using a command "previous"? I
could've sworn I've seen it somewhere before.


  #3   Report Post  
Scott S
 
Posts: n/a
Default

Thanks a million!




"Gord Dibben" wrote:

Scott

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

Function PrevSheet(rg As Range)
'Enter =PrevSheet(B1) on sheet2 and you'll get B1 from sheet1.
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 31 sheets, sheet1 through sheet31.

Select sheet2 and SHIFT + Click sheet31

In 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 InsertModule. Paste the above code in there. Save the
workbook and hit ALT + Q to return to your workbook.


Gord Dibben Excel MVP


On Sun, 27 Feb 2005 15:55:03 -0800, "Scott S" <Scott
wrote:

I have a file with 31 worksheets, one for each day of my accounting period.
Each worksheet is divided into 2 parts, daily and period to date. I am
trying to calculate the rolling totals each day. I can do it, but reentering
the manipulated formulas for each day is very time consuming. Isn't there a
way to pull data from a previous worksheet by using a command "previous"? I
could've sworn I've seen it somewhere before.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I collect data from an interactive web worksheet and impor. worksheetmom Excel Discussion (Misc queries) 3 February 20th 05 12:38 AM
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM
Pulling data from 1 sheet to another Dave1155 Excel Worksheet Functions 1 January 12th 05 05:55 PM
Reference Data in Moved Worksheet tommcbrny Setting up and Configuration of Excel 1 December 1st 04 06:49 PM
Automatically pull data into another worksheet within the same fil TJess Excel Worksheet Functions 1 November 15th 04 08:00 PM


All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"