Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default how do I reference a cell in a previous sheet not by name, by orde

I have an inventory of stock with formulae to calculate
"StartOfDay + Deliveries - Sales = EndOfDay"
I'm trying to write or record a macro to create a new worksheet and copy
EndOfDay from the previous days worksheet into the StartOfDay of the new
worksheet.
When I record the macro it records the actual name of the sheet ie
"Sheet4!E2" which does not give the incremental effect needed. Something like
"Sheets.Previous!E2" is needed

Cheers!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default how do I reference a cell in a previous sheet not by name, by orde

Maybe you could use a named range for something like this...

Mark Ivey

"I.P.Phrielie" wrote in message
...
I have an inventory of stock with formulae to calculate
"StartOfDay + Deliveries - Sales = EndOfDay"
I'm trying to write or record a macro to create a new worksheet and copy
EndOfDay from the previous days worksheet into the StartOfDay of the new
worksheet.
When I record the macro it records the actual name of the sheet ie
"Sheet4!E2" which does not give the incremental effect needed. Something
like
"Sheets.Previous!E2" is needed

Cheers!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default how do I reference a cell in a previous sheet not by name, by orde

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

Sub newone()
Worksheets.Add
ActiveSheet.Range("A1").Formula = "=PrevSheet(E2)"
End Sub


Gord Dibben MS Excel MVP

On Sat, 2 Feb 2008 22:15:11 -0600, "Mark Ivey" wrote:

Maybe you could use a named range for something like this...

Mark Ivey

"I.P.Phrielie" wrote in message
...
I have an inventory of stock with formulae to calculate
"StartOfDay + Deliveries - Sales = EndOfDay"
I'm trying to write or record a macro to create a new worksheet and copy
EndOfDay from the previous days worksheet into the StartOfDay of the new
worksheet.
When I record the macro it records the actual name of the sheet ie
"Sheet4!E2" which does not give the incremental effect needed. Something
like
"Sheets.Previous!E2" is needed

Cheers!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default how do I reference a cell in a previous sheet not by name, by orde

Never mind... I worked it out thanks...

"I.P.Phrielie" wrote:

I have an inventory of stock with formulae to calculate
"StartOfDay + Deliveries - Sales = EndOfDay"
I'm trying to write or record a macro to create a new worksheet and copy
EndOfDay from the previous days worksheet into the StartOfDay of the new
worksheet.
When I record the macro it records the actual name of the sheet ie
"Sheet4!E2" which does not give the incremental effect needed. Something like
"Sheets.Previous!E2" is needed

Cheers!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default how do I reference a cell in a previous sheet not by name, by orde

The worksheet object as a Previous property, e.g.

Set wks = ActiveSheet.Previous


--
Tim Zych
SF, CA

"I.P.Phrielie" wrote in message
...
I have an inventory of stock with formulae to calculate
"StartOfDay + Deliveries - Sales = EndOfDay"
I'm trying to write or record a macro to create a new worksheet and copy
EndOfDay from the previous days worksheet into the StartOfDay of the new
worksheet.
When I record the macro it records the actual name of the sheet ie
"Sheet4!E2" which does not give the incremental effect needed. Something
like
"Sheets.Previous!E2" is needed

Cheers!





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default how do I reference a cell in a previous sheet not by name, by

Thanks everyone, but,

after 2 days of trying to find the answer in typically unhelpful "Help"
files I recorded the Macro using 'Crtl+PgUp' and 'Ctrl+PgDn' keys to navigate
between the sheets instead of the mouse... the resulting code for switching
between the sheets came out as "ActiveSheet.Previous.Select" and
"ActiveSheet.Next.Select"

I stumbled across the solution 2 minutes after posting... hahaha

Hope this helps someone else

"Tim Zych" wrote:

The worksheet object as a Previous property, e.g.

Set wks = ActiveSheet.Previous


--
Tim Zych
SF, CA

"I.P.Phrielie" wrote in message
...
I have an inventory of stock with formulae to calculate
"StartOfDay + Deliveries - Sales = EndOfDay"
I'm trying to write or record a macro to create a new worksheet and copy
EndOfDay from the previous days worksheet into the StartOfDay of the new
worksheet.
When I record the macro it records the actual name of the sheet ie
"Sheet4!E2" which does not give the incremental effect needed. Something
like
"Sheets.Previous!E2" is needed

Cheers!




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 reference the same cell in all previous sheets? Joe Lewis[_2_] Excel Discussion (Misc queries) 3 November 24th 08 03:47 PM
How can I reference a cell on a previous worksheet Kim Excel Discussion (Misc queries) 3 August 18th 08 12:10 PM
reference to previous cell (always) Harvey Excel Discussion (Misc queries) 5 January 27th 07 12:02 AM
Relative reference to a cell on a previous sheet [email protected] Excel Discussion (Misc queries) 1 July 17th 06 07:27 PM
Reference Previous Sheet [email protected] Excel Worksheet Functions 18 October 8th 05 08:34 AM


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

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

About Us

"It's about Microsoft Excel"