Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
 
Posts: n/a
Default Reference Previous Sheet

Hi I've found on this newsgroup a function to get the previous sheet
name

Function PrevSheet()
On Error GoTo EndFunction
Application.Volatile True
PrevSheet = Application.Caller.Worksheet.Previous.Name
Exit Function
EndFunction:
With Application.Caller.Parent.Parent.Worksheets
PrevSheet = .Item(.Count).Name
End With
End Function

when i put =PrevSheet() i get the previous sheets name

What i want to be able to do is use this in place of directly
referencing the sheet name in my code as follows...
=IF(G4-J4<0,G4-J4,G4-J4)+'Week 1'!H4
So i want to be able to replace Week 1 with PrevSheet but i've tried
and falied on this. eg...

=IF(G4-J4<0,G4-J4,G4-J4)+PrevSheet()!H4
Could someone show me the correct syntax for this.

Cheers many thanks in advance.

  #2   Report Post  
Max
 
Posts: n/a
Default

Instead of ..
=IF(G4-J4<0,G4-J4,G4-J4)+PrevSheet()!H4


Maybe try something like:
=IF(G4-J4<0,G4-J4,G4-J4+INDIRECT("'"&PrevSheet()&"'!H4"))

(lightly tested, seems to work ok if we use INDIRECT)
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--
wrote in message
ups.com...
Hi I've found on this newsgroup a function to get the previous sheet
name

Function PrevSheet()
On Error GoTo EndFunction
Application.Volatile True
PrevSheet = Application.Caller.Worksheet.Previous.Name
Exit Function
EndFunction:
With Application.Caller.Parent.Parent.Worksheets
PrevSheet = .Item(.Count).Name
End With
End Function

when i put =PrevSheet() i get the previous sheets name

What i want to be able to do is use this in place of directly
referencing the sheet name in my code as follows...
=IF(G4-J4<0,G4-J4,G4-J4)+'Week 1'!H4
So i want to be able to replace Week 1 with PrevSheet but i've tried
and falied on this. eg...

Could someone show me the correct syntax for this.

Cheers many thanks in advance.



  #3   Report Post  
 
Posts: n/a
Default

Hi just found IDIRECT just before I read your message.


It works great thanks.

Cheers for you help
:)

  #4   Report Post  
Max
 
Posts: n/a
Default

Glad it worked out !
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--


  #5   Report Post  
 
Posts: n/a
Default

Although it works fine i now wish to be able to drag down the cell so i
get
=IF(G4-J4<0,G4-J4,G4-J4)+INDIRECT("'"&PrevSheet()&"'!H4")
=IF(G5-J5<0,G5-J5,G5-J5)+INDIRECT("'"&PrevSheet()&"'!H5")
=IF(G6-J6<0,G6-J6,G6-J6)+INDIRECT("'"&PrevSheet()&"'!H6") etc...

I IF part works. However the indirect bit stays at H4 eg..
=IF(G5-J5<0,G5-J5,G5-J5)+INDIRECT("'"&PrevSheet()&"'!H4")

I really dont want to have to manually go to each and change that
because i have hundreds of rows. Any suggestions?

Cheers in advance



  #7   Report Post  
 
Posts: n/a
Default

I'm guessing because H4 is between is in between the quotes ""

  #8   Report Post  
 
Posts: n/a
Default

With regaurds to changing the cell reference..
I've sort of got a hashed together solution

In A1 i write =PrevSheet()
In B1..B100 etc i write H4 , H5 ... H100

In the C colm i put
="'"&$A$1&"'"&"!"&B1
="'"&$A$1&"'"&"!"&B100 etc...

In the D colm i put =INDIRECT(C1), =INDIRECT(C2) ... =INDIRECT(C100)

This gives me the values i want and works but its a bit of messing
about!

Is there any easier ways to do this??

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
Refer new sheet to previous sheet Spot Excel Worksheet Functions 2 September 9th 05 02:05 PM
reference sheet tab name in a cell wendyvan Excel Discussion (Misc queries) 1 May 17th 05 03:38 PM
Absolute Worksheet reference number Tony M Excel Discussion (Misc queries) 4 March 21st 05 06:10 PM
linking multiple sheets to a summary sheet greg g Excel Discussion (Misc queries) 1 December 16th 04 07:43 AM
referring to previous sheet Iolao Excel Discussion (Misc queries) 3 November 26th 04 08:40 PM


All times are GMT +1. The time now is 10:55 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"