# Refer To Previous Sheet

Nov 24, 2009

I've got a workbook that increments in sheets for each new week. I have a cell showing the current week number for that sheet ( lets say cell C1) and any formulas that need to reference data from the previous sheet do in 'indirect' function which basically looks at the current week number ( lets say week 20)in cell C1 and minus's 1 to navigate to the previous week (week 19).

I was wondering if there was a way to reference the previous sheet purely by the order they're in.

So say i have 5 sheets named "1,4,5,8,9" and these represent week numbers so the sheet named '8' in cell C1 would have '8' standanding for the week number but cells that wanted to reference the previous sheet couldn't do the 'indirect' C1-1 as there is no 'week 7'.

The weeks used could vary alot so a formula to reference the directly previous sheet is needed.

ok, thought best if i show you the actual formula

=IF(ISBLANK(C12),"",IF(ISERROR(VLOOKUP(C12,INDIRECT("'"&(\$AG\$2-1)&"'!\$C:\$AG"),28,FALSE)),G12,SUM(G12,VLOOKUP(C12,INDIRECT("'"&(\$AG\$2-1)&"'!\$C:\$AG"),28,FALSE))))

the '\$A\$G2-1' part is the bit that redirects to the previous sheet based on it's name, what i think i really need is to replace this part with a 'PrevSheet' function but i'm unsure how.

## Use INDIRECT To Refer Sheet Name

May 9, 2014

I have multiple sheets as Name1 ; Name2 ; Name3 and each sheet have a value on cell A1 for any number let say between 0 to 100. On another sheet call SheetName, I have A1=Name1 ; A2=Name2 ; A3=Name3.

I have formula as:

[Code] .....

The INDIRECT formula work to refer each cell A1 in each sheet, however if the sheet name include a space then it won't work anymore. How to make it work with the sheet name with space?

## Refer To Sheet By Secret Name

Jun 9, 2006

When I look in VBA under the Microsoft Excel Objects at the sheet names in my workbook I see two names for the same sheet like so:

sOrdersFB(Orders From Bob)

how to select using the first name sOrdersFB?

## Refer To A Sheet's Codename From Another Workbook?

Apr 17, 2009

I want to be able to safeguard against a user changing the name of a worksheet, so I use the sheet's codename in all my macros.

I have the codename of a sheet: shOptions

From a different workbook, "ActiveWorkbook.shOptions" doesn't work. How can I use "shOptions" in the other workbook.

## Subscript Out Of Range - Refer To Sheet?

Jun 8, 2012

Dim k as string
K = "sheet1"

Sheets(k).select

This is the code 'm using

## Table To Refer To Sheet Names

Nov 23, 2006

I have 50 sheets (1 sheet per staff member) that will be linked to a Master Sheet that compiles the data. The staff members are based in 5 teams of 10. The names of the sheets are based on the person's initials plus the words Progress Day,

All formulas in the master sheet are based around linking to 10 sheets so I can view the performance of each team. My problem is that the composition of each team changes quite often and so the links have to be manually updated for each team. Is there any way, for example, of compiling a table of team initials like the one below:

AT
EF
FY
DE
CB
RO
PR
TA
NE
SK
HS

that could easily be edited so that the formulae containing the sheet names relate to the table rather than static sheet names?

Eg., If AT left the above team and was replaced by PG then I would update the list above and the current formula

='C:Documents and SettingsAll UsersShared DesktopProgress Day Daisychain[AT Progress Day.xls]Sheet1'!D32+'[EF Progress Day.xls]Sheet1'!D32

would update to:

='C:Documents and SettingsAll UsersShared DesktopProgress Day Daisychain[PG Progress Day.xls]Sheet1'!D32+'[EF Progress Day.xls]Sheet1'!D32

## Sheet Name Stored In Cell - Refer To In Formula

May 31, 2006

Sheet names in Col B
B2 : Sheet1
B3 : Sheet2
Etc

I tried

=INDIRECT(B3,\$J\$58)

at C3 where \$J\$58 is the cell I would like to reference on 50 different sheets

Formula returns #REF!
Col C ref's \$J\$58
Col D ref's \$L\$58
Col E ref's \$N\$58
Col F ref's \$P\$58

So as I copy the 4 formulas down, the ref to the correct sheet should update but the cell ref's should remain

## Delete Range Names That Refer To Sheet

Dec 19, 2006

I am looking for a way to delete all the range names in a worksheet, not the whole workbook. I have found several procedures that will delete all the names in an activeworkbook. For some reason it takes too long to run. Does anyone know how to handle a single sheet in VBA?

## Sheet Indirection. Refer To Sheets With Changing Names

Feb 25, 2008

I've been referencing sheets in my code directly with things like

Sheet1. Range(NamedRange)

however in recreating a new workbook (to reduce bloat), the sheet-numbering has changed... to avoid having to mess around adjusting things again, I was wondering if it's possible to do some sort of indirection... something similar to

#define SHEET_SC_CONFIG Sheet1
#define SHEET_CUSTOMER Sheet2

'and then use these throughout the code....
SHEET_SC_CONFIG.Range(NamedRange)

(cannot reference by sheet name, as end user may change these)

## Update A Cell Value From A Previous Sheet After Copying The Sheet And Renaming It

Nov 21, 2009

I have copied a sheet, moved it to the end and renamed it with a date that is in cell "A1"

Now after that process is finished I need it to update the date in cell "A1" of the newly created sheet with the next day's date.

I am stuck however referring to the previous sheet to update the date value in "A1"

## Update Sheet From Previous Sheet

Feb 9, 2009

what im hoping to do is when i press macro button"click to sort" on sheet totals

it will automatically input the totals from "TOTALS" underneath the right name and put the date in column a the trouble is the cells are dependant on the sort so if i was to press "click to sort" now it would transfer this data to sheet "PTS AND DATES"

09/02/09 in cell a2
1146 in b2
861 in c2
860 in d2
849 in e2
806 in f2

the very next time i press it , it will put data into row 3.

## Reference Previous Sheet

Oct 5, 2005

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.

## Goto Previous Sheet

Apr 3, 2007

I am writing a macro that goes from one sheet to another sheet to copy data but then must return to the 1st sheet to paste it.

Is there a command for returning to a previous sheet.

Note that the sheets may not necessarily be in consecutive order ie. the 2nd sht may not be immediately after the 1st sheet in the sheet tab order.

The spreadsheet will be made up of a number of sheets that can use the same macro to reference a master sheet to copy and return data.

## Select Previous Sheet Macro

May 1, 2013

Below is a macro I'm trying to create. The basically it's supposed to be a quick simple macro to save lots of time. I want to select current tab, move/copy (create copy) to the end....then select the tab I've just copied and copy paste special the values (then rename the tab to todays date) FYI the tab I'm copying is called rebuy shipping.

However, I want to then do the same at a later date with the most recent tab, but with the below code it always selects and copies the original tab:

'
'
' Keyboard Shortcut: Ctrl+k
'

[Code] .....

I assume this is a simple error. I've tried inserting Activesheet.previous.

## Cell Reference To Previous Sheet?

Jan 13, 2011

We have a sizeable Excel workbook that contains many worksheets for various things, everything works smoothly except for one minor niggle.

I am looking for a formula that references to a cell on a previous worksheet, the worksheet could be named anything (eg A1, B, 2, 3.4, etc). Then to add 1, ideally the first worksheet inserted must equal, say, 0 BUT can reference the sheet previous as this is a constant; so something along the lines of...

Cell A1 =magic formula
Cell A2 =A1+1

This is to get a vlookup to work consistently.

OR another option is, for the worksheet to reference an already populated worksheet and read down a table by adding one to reference the cells. Eg first sheet reads ='schedule'!A13, the next sheet added would read A14 then A15 etc...

OR a worksheet (like page numbers) count into a cell onto each worksheet inserted, eg on worksheet 6 in cell A1 the number 6 would be inserted then worksheet 7 would have 7 inserted into A1 etc..

## Back To Previous Active Sheet?

Aug 22, 2014

I'm listing through sheets and have Sheet2 for drop-down lists.

Sheet2 is not visible, but when I click on Cmdbutton It appears so that I can change values in drop-downs. When I hide Sheet2 again, I want to be back on sheet before Sheet2.

My code for open and close sheet2 :

[Code].....

How can I do that ?

## Back Button Go Previous Sheet

Nov 14, 2008

I am working within a workbook with many worksheets and I want the ability to go back to the previous sheet I was on (example - I am on sheet 23, go to sheet 16, I want to be able to have a button or link that takes me back to sheet 23)

## Formula Referencing Previous Sheet

Jun 29, 2009

After a formula to copy the contents of a cell in the previous sheet in a workbook, so that if I was to copy the last sheet in a workbook the formula would automatically reference the cell from the copied worksheet and so on if I copied tht one.

Hope this makes sense I have a lot of formulas referencing the previous sheet and everytime I copy this sheet to create a new sheet I have to change the sheet number in the formulas.

eg, in sheet 8 this formula get info from sheet 7 cel J30 ='7'!J30 when i copy the sheet to create a new one (Sheet 9) I would like the new formula to automatically be ='8'!J30.

## Macro For Next & Previous Sheet Selection

Sep 6, 2007

I have created a toolbar that has "Previous Worksheet" and "Next Worksheet" buttons on it with the following macros assigned:

Sub NextSheet()
On Error Resume Next
If ActiveSheet. Name = "Problem Listing" Then
MsgBox "This is the last worksheet."
Else
ActiveSheet.Next.Select
End If
End Sub

Sub PreviousSheet()
On Error Resume Next
If ActiveSheet.Index = 1 Then
MsgBox "This is the first worksheet."
Else
ActiveSheet.Previous.Select
End If
End Sub

This seems really simple but the code crashes after 4 or 5 repeated clicks of the button.

## Save Previous Cell Value In The Corresponding Row Of Different Column In Same Sheet

Apr 4, 2014

I found some VBA code that saves the previous value entered into a cell and displays it as a comment. I've attached that workbook as an example, but I want to change 3 things.

1) I only want to capture the previous values from Sheet1.Column1 (you'll see the example captures changes on the whole sheet1).
2) I want to 'paste' the previous value of Sheet1.Column1 in the corresponding row of Sheet1.ColumnD (i.e. the previous value of A5 will be displayed in D5). The code currently pastes the value in the corresponding address in sheet2.
3) I do not need the comments part. Simply displaying the previous value in the corresponding row of Sheet1.ColumnD is good enough.

## VBA For Insert Previous Month In Sheet Name On Open

Feb 28, 2007

I'd like to make a template so that when it is opened the previous month name is inserted in the sheet name. The reason I want to use previous month is that normally this report is created in the month following the month being reported. So it is opened, months are updated, then the user saves as xls. Ideally I guess sheet would not have the month on the template.

The name of the sheets are shortened months like "Dec Results Bob" and there are 8 of these.

I can tell it might start:

Private Sub Workbook_Open() (or would .xlt be the same?)

but that's about it. I made a macro of renaming sheet but that didn't really tell me if I could insert the Month there.

## Auto Updating Formula To Previous Sheet

Aug 13, 2009

if it is possible te refer to a cell in another worksheet.

I have 10 worksheets in sheet one I put in cel A4 a digit en sheet 2 I put the formula that refers to sheet 1 cel A4.

Now I want a formula that refers to sheet -1 so in sheet 3 the formula automatically refers to sheet 2 cel A4 and in sheet 4 the formula automatically refers to sheet 3 cel A4 without corrections to the formula.

## Find Last Previous Non Blank Value And Summarize Previous 6 Months?

Dec 10, 2012

see attached file. Need to find latest non blank value - in attached file it is highlighted in yellow. From there, want to summarise 26 weeks back so, in the attached file:

Row 2 would be finding 750 and summarised back 26 weeks from 30 sep 2012
Row 3 would be finding 2250 and summarised back 26 weeks from 2 dec 2012
Row 4 would be finding 5000 and summarised back 26 weeks from 4 nov 2012

## Automatically Generate Template Sheet Based On Previous Data

Apr 17, 2014

I currently have a large spreadsheet that multiple people fill out. Each person fills out all the information in a row. At the end of the row, I would like a button that says "Generate Form" so that when clicked, a new sheet automatically opens with a template form that I created and is already filled out with the information that was just inputted into the spreadsheet. Also, there are four different template forms that could generate. For example, there are forms A, B, C and D. If the user inputs "B" into the first column of the row, then when he goes to click "Generate Form", a new sheet is created with all the information filled out in Form B.

## Automatically Go To Previous / Last Active Sheet After Macro - Like IE Back Button

Jun 28, 2012

let's say I run a macro from a button on sheet 3, macro process on sheet 10. Is there a way that the macro would automatically go back to sheet 3? Like a "Back" button on IE. I can't code Sheets("sheet 3").Select because I want it to do the same thing on sheet 4,5,6...

## Copy A Formula Across Several Work Sheet And Have The Formula Always Take Data From Previous Work Sheet

Jan 2, 2009

I am want to copy a formula across several work sheet and have the formula always take data from previous work sheet.

2) I am working with this formula =C12+INDIRECT((MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)-1)&"!"&"C12")

and it comes from this thread http://www.excelforum.com/excel-gene...orksheets.html. I have included a worksheet attachment that has explanations

## VBA To Refer To Outlook

Jun 18, 2009

In Excel, I want VBA to refer to the SENT ITEMS folder in Outlook. I want to loop over all sent items, and if the email address satisfies a condition, then record that fact in Excel. I am good at VBA in Excel, and I have a passing knowledge of VBA in Outlook, but I don't know how to refer to Outlook within my Excel VBA.

## Refer To Combo Box In VBA

Sep 14, 2009

How do I refer to a combo box (form control) in a calculation. EG: how can i say if comboBox = Something then ....

## Refer To More Than One Workbook

Nov 9, 2009

I'm using this code to open another workbook:

Dim FileToOpen
FileToOpen = Application.GetOpenFilename _
FileFilter:="BlankSAMSRegister.xlsm (*.xlsm),")
If FileToOpen = False Then
MsgBox "No file specified.", vbExclamation, "Error"
Exit Sub
End If
Once this second workbook is open, how do I refer to each one within the subsequent code?

I really need the parent workbook to be named as wb1 and the child to be names wb2 so I can flick between the two in the next macro... I can get the parent using thisworkbook.name, but how do I get the child?

## Refer To A Checkbox Value By Vba

May 10, 2007

I have a check box whithin a worksheet. This CheckBox doesn't have any linked cell, and doesn't have any macro asigned. know I would like to refer to the value of the checkbox by vba kind of: ?ActiveSheet.Shapes("CheckBox1").value=true 'from the vba's inmediate window