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)

View 6 Replies


ADVERTISEMENT

VBA Select Multiple Sheets Of Varied/Changing Sheet Names

May 18, 2006

How can I select sheets in a workbook based on the premise that the sheetname does not have the letter "Q" in it? New to forum, so apologies if format is not kosher.
I have a group of 50+ workbooks which are all set up in the following format:

-Contains 30+ sheets.
-Sheet names are varied, but follow a pattern. I try to keep the sheet names consistant on all workbooks so that it is easier to reference, but other users make this impossible.
-However, I managed to keep two things consistant: There are two categories of sheets. In one group all sheetnames have a "Q" in them and in the other group all sheetnames DON'T have a "Q" in them.

Here is my problem: I need to run a macro to perform retative tasks on the GROUP OF SHEETS WITHOUT A "Q". To begin the macro I need to select these sheets and copy them to a new workbook, but since the actual sheetnames are varied, I am having trouble coming up with a flexible way of selecting sheets. The closest I have come is using a IF ... LIKE ... THEN statement, but I can only get it to work to select the sheets with a "Q" in the name and not the opposite.

View 2 Replies View Related

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

View 5 Replies View Related

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?

View 6 Replies View Related

Hyperlink Index To Changing Sheets Tab Names

Jan 11, 2008

I have a long list of tabs listing "projects" which have changing names - on the first sheet, I want to have the table of contents automatically update and link to each tab - I want the user to only have to change the tab name to have the table of contents and link update -

View 5 Replies View Related

Excel 2010 :: VBA - Hide Sheets Using Code Names Not Sheet Names

Oct 15, 2013

Code:

Sheets(Array("Sheet 1", "Sheet 2")).Visible = False

How do I convert the above to using Sheet Codes Names, Sheet1 and Sheet2?

Want to ensure my code will work if the user changes the sheet name.

View 2 Replies View Related

Continual Changing Sheet Names

Nov 24, 2008

I want to capture data from another workbook each month where the sheet name that I need the data from changes each month. i.e. 0810, 0811, 0812, 0901. Are possible sheet names. I've tried to build this unsuccessfully into the my -

View 5 Replies View Related

Chart Data Series Refer To Defined Names

Jan 15, 2014

I'm trying to use some defined names to create charts. Though it works at the very begin, some extremely weird things happen when I try to develop further .....

Attached please find the test file, which simplifies my real case but shows the same problem.

Test.xlsx

In the test file, three names are defined as below:

Line1: "=Xvalue*1"
Line2: "=Xvalue*2"
Xvalue: "=ROW(SampleChart!$A$1:$A$25)"

the chart is very sample: "=SERIES(,Test.xlsx!Xvalue,Test.xlsx!Line1,1)"

So far, it works very well. However, I just simply can't add the second line into the chart, for example, "=SERIES(,Test.xlsx!Xvalue,Test.xlsx!Line2,2)"

I canNOT even change "Line1" to "Line2" in the "SERIES" formula!

View 5 Replies View Related

Reference Sheets With Variable Sheet Names

Dec 4, 2007

I have a workbook with multiple sheets. There is an overview sheet and then 14 sheets allowing for 14 days worth of schedule information. There are then 3 sheets following the 14 days to total some information. The workbook users frequently change the sheet names of the 14 sheets to reflect days of the week.

I'm creating a copy for distribution that takes the active workbook and copies the values to a new workbook. There are columns that I would like to delete from the 14 day sheets and that would be easy enough if the sheet names were never changed.

The code I'm using currently follows (my thanks to Turtle 44 for helping on that section)

Sub Copy_Visible_Sheets()
Dim arr() As String
Dim i As Integer
Dim WB As Workbook
Dim WS As Worksheet
Set WB = ActiveWorkbook
Application. ScreenUpdating = False

'Make sure template is saved as .xls
If Not ThisWorkbook.Saved Then
MsgBox "Please save this workbook before generating a Client Copy."
Else

View 6 Replies View Related

Referencing To Sheet Names While Consolidating Data From Various Sheets

Feb 23, 2014

I am writing a macro to consolidate data from different worksheets in more than one Summary Sheets.

My workbook has quite a number of worksheets, from different department e.g. OPS001, OPS002,OPS003, ADMIN001, ADMIN002, ADMIN003 and so on.

I want data from OPS001, OPS002 and OPS003 to go on one sheet e.g. "Summary-OPS" and data from ADMIN001, ADMIN002 and ADMIN003 to go on the other sheet name "Summary-Admin"

When I am working on Summary-Ops sheet I want to copy data from sheets starting with name "OPS" and so on.

View 3 Replies View Related

VBA Code For Listing The Sheet Names Of Deleted Sheets

Oct 20, 2008

I have a workbook with 20+ sheets in it, I add sheets and delete sheets on a daily basis, except for one sheet that is like my summary sheet.

Is there a code, formula, or magic spell that will list the names of the sheets that I have deleted? For instance, if my workbook has 50 sheets and I delete 49 of them, I want to see cells A1 thru A49 (or where ever I wish to place them) filled with the names of the sheets I just deleted.

View 9 Replies View Related

New Lines To Refer To Different Sheets

Nov 20, 2009

=COUNTIF(A2&"_RES","Yes")

A2 refers to a linked cell but I have tried without the link there still no joy. Together they would generate for example "DCA_RES" which would refer to a column range in a different sheet on the same workbook.

I want this to work so that I can implement more easily new lines to refer to different sheets. (Drag to copy) instead of having to copy and edit a formula 100 times.

View 6 Replies View Related

Indirection Be Done In VBA

Jul 11, 2008

I suppose I'm hoping the answer is 'no', having once inherited a system written in M+ where a scally contract developer had used 3 or more levels of indirection to make the system totally unmaintainable by anyone except himself (easiest option was to rewrite it which alas for him made the contractor unnecessary). Also if you recurse on an indirected variable you swiftly crash the op system stacks.

It's simple enough to indirect to references on the worksheet, but I just wondered if you can indirect on variable names in VBA? There's nothing in the help file so I assume not.

View 9 Replies View Related

Refer To Sheets Created In Loop

Oct 16, 2007

I need to creat a bunch of sheets and do the same work for each of the sheets. My problem is that I do not know how to refer them by the created name. Here is an example of my codes:

Sub test()
Dim I As Integer

For I = 1998 To 2010
Sheets.Add.Name = I
Sheets("Number").Activate
Range("A1:A3").Select
Selection.Copy
Sheets(I).Select
Range("A1").Select
Selection.Paste

Next I

End Sub

The error is "Subscript out of Range". I believe it is because when I refer a sheets(I), (I) does not recognize as the name of the sheet but the number of that sheet, and there is no sheet numbered 1998 or bigger. However, If I refer the sheet as sheets("I"), it can not find the sheet named "I" either.

How should I refer those sheets name so that I can do some work?

View 7 Replies View Related

Stop Procedure Window Changing When Changing Sheets

Sep 9, 2007

Moving between different sheets changes the procedure window, which is a good thing, but can also can be error prone and annoying to search through several windows searching for the procedure or module currently working on. Is there a setting somewhere to prevent VBE from changing the current procedure window?

View 4 Replies View Related

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?

View 5 Replies View Related

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.

View 11 Replies View Related

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?

View 9 Replies View Related

Copy / Paste Frequently Changing Data From 4 Sheets Into One Master Data Sheet

Jul 4, 2012

I have a workbook that includes 4 seperate sheets that are used to record time and expenses for 4 members of staff. I want to write a macro to select the data I need from each sheet and colaberate together in a 'data' sheet so I can combine all the info to run time and expense reports per client showing combination of all time and expense incurred from all 4 staff.

I have named cell ranges in each of the 4 time-sheets. I proceed to record a macro, select the first named range, copy and paste into my data sheet, do a control home then control down arrow, then one more down arrow to get to the first blank cell and repeat the process for all four time-sheets.

This works until I add a new line and then the data will only appear for the last time-sheet (last row of data).

View 2 Replies View Related

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.

View 14 Replies View Related

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

View 9 Replies View Related

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

View 2 Replies View Related

Can Create Data Validation List Of Names Created In Name Box Or Sheet Tab Names

May 7, 2012

Can I create data validation list of the names created in the name box or of the sheet tab names?

View 5 Replies View Related

Changing Order Of Names

Jul 20, 2009

Can this be done with a formula?:

Smith, John

changed to:

John Smith

View 11 Replies View Related

Changing Worksheet Names Anywhere Between 50-100

Jan 24, 2008

I would like to change the worksheets names (many, anywhere between 50-100) to a cell (A2) value in each of the worksheets.

View 9 Replies View Related

Changing Tab Names Using VBA Script

Dec 30, 2008

I'm creating a spread sheet which contains 52 tabs (1 for each week). Instead of manually naming each tab, I would like to create a VBA script that automatically renames each tab using the following naming convention, wk end 1-2, wk end 1-9, wk end 1-16, etc.

I'm not familiar with how to write VBA code and would like some assistance in writing the script correctly.

View 9 Replies View Related

Create Array Of File Names/sheet Names

May 1, 2008

Two part question:

1) I'm relatively new to arrays, but what I need to do is generate a list of file names and the sheets within each one. I would like to use an array for this, but since I don't have much experience.... well....that's why I'm here. Can someone point me in the right direction?

2) And the second part of this.... I was planning on using the FileSystemObject to determine the files in a selected folder and loop through that list of files, opening each one and harvesting the required info (file name and all sheet names). Should I use the FSO or is there something built into Excel that might be better (and also limit the number of dependencies for this little "project" of mine).

View 9 Replies View Related

List Sheet Names And Internal Names Within Workbook

Feb 25, 2011

Is it possible to produce a list on a new worksheet of all sheet names and their their internal names within a workbook?

If so I would like the tabbed name's to begin in say A2 with the corresponding internal name in B2.

View 3 Replies View Related

Changing File Names Within Worksheets

Mar 25, 2009

my formula is as follows: =(VLOOKUP(A7,'[Monthly AR Analysis - Feb09.xls]AR - Current'!$A$1:$I$153,8,FALSE)). I will be using this for formula on about 15 different worksheets ... my issue is the file name changes every month and currently I have to go in and do a find and replace, I would like to have one main page where I could change the file name month and it will change all the rest.

ie: Monthly AR Analysis - Feb09.xls next month changes to Monthly AR Analysis - Mar09.xls .... So basically each month I want it to pick up the new file that has been saved with the new name. So what I would want is to be able to have a cell that I could change the Feb09 to Mar09 and then it would do the same to all the worksheets. I attempted to use CONCATENATE to change file name and it worked but will not work within the Vlookup.

View 4 Replies View Related

Names Changing In Pivot Table Macro

Jul 19, 2013

I am running into an error when creating a macro to make a pivot table and sum certain columns. I am fairly certain this is due to the name changing to PivotTable2, 3, 4, etc. each time. Is there a way to make the name stagnent so when a table is created in the macro it doesn't error out the formulas? I have an example below.

Code:

Columns("A:D").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Data!R1C1:R1048576C4", Version:=xlPivotTableVersion14).CreatePivotTable _
TableDestination:="Pivot!R1C1", TableName:="PivotTable5", DefaultVersion _
:=xlPivotTableVersion14

[Code] .........

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved