Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default Accessing Other Sheet Tabs from within Excel

Is there any easy way to refer to sheets without knowing the name of the sheet?

e.g. A summary sheet that collates details for the company from all other
sheets within the workbook which may be different branches and/or personnel.

These extra tabs may be added or have their tab name changed at any time,
and I do not wish to redo the summary sheet each time.
Ideally I would like to know how many other sheets there are are and to be
able to reference instead of 'Freds Sheet'!.$A$7 to be something like
WorkSheet[3]!.$A$7, with some method of checking the range of sheets - the
summary could always be the first sheet.

The sheets, other than the summary, would all be in the same format, so that
the data required would be accessed from 'fixed' cells.

--
Eric Hargreaves
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Accessing Other Sheet Tabs from within Excel


Sub blah()
NumberOfSheetsToProcess = ThisWorkbook.Sheets.Count - 3 '3 from below
MsgBox NumberOfSheetsToProcess & " sheets to summarise."
For Each sht In ThisWorkbook.Sheets
Select Case sht.Name
Case "Sheet name not to be processed", "Summary", "leaveMeAlone" '
3 here
'do nothing
Case Else
MsgBox "about to process sheet '" & sht.Name & "'"
'do lots of summarising using sht as your way of referencing that
sheet
End Select
Next sht
End Sub


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=127378

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default Accessing Other Sheet Tabs from within Excel

Thanks for your info, I haven't had chance to try it yet, but I was hoping to
be able to code a cell with something of the order:-
=if(Row()Worksheets.Count,"",Worksheet[Row()]!$A$7)
instead of
='Freds Sheet'!$A$7

Is this a possibility?
--
Eric Hargreaves


"p45cal" wrote:


Sub blah()
NumberOfSheetsToProcess = ThisWorkbook.Sheets.Count - 3 '3 from below
MsgBox NumberOfSheetsToProcess & " sheets to summarise."
For Each sht In ThisWorkbook.Sheets
Select Case sht.Name
Case "Sheet name not to be processed", "Summary", "leaveMeAlone" '
3 here
'do nothing
Case Else
MsgBox "about to process sheet '" & sht.Name & "'"
'do lots of summarising using sht as your way of referencing that
sheet
End Select
Next sht
End Sub


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=127378


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Accessing Other Sheet Tabs from within Excel


Yes, I realised just after posting that you'd asked this in the
-Worksheet Functions- section of codecage.
In answer to your question, I very much doubt it.
However, although it's not something I've done myself yet, do a search
for
"*Consolidation*" or "*Consolidate data in multiple worksheets*" in
Excel Help. It seems there is built-in functionality that might be able
to help you.


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=127378

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,069
Default Accessing Other Sheet Tabs from within Excel

If I understand correctly, you want a function you can enter in, say, A2 on
your summary sheet and copy down. On row 2, it would pull the value in A7
from the second sheet in the workbook. On row 3, it would pull the value in
A7 fromthe third sheet, etc.

If you are always pulling numeric values from the other sheets, you can use
this used-defined function (UDF):

Public Function GetShtVal(CurrRow As Long, GetRng As String) As Variant
On Error GoTo GSVerr
If CurrRow ThisWorkbook.Sheets.Count Then
GetShtVal = vbNullString
Else
GetShtVal = ThisWorkbook.Sheets(CurrRow).Range(GetRng).Value
End If
Exit Function
GSVerr:
GetShtVal = Error()
End Function

In A2 (for example) on your summary sheet, you would enter
=GetShtVal(ROW(),"A7")+(NOW()*0)

The Now()*0 is necessary to force Excel to recalculate the formula (the UDF
won't automatically recalc).

If you are always pulling text values, you can use the same UDF, but the
fomula on the worksheet will have an ampersand instead of the plus sign:
=GetShtVal(ROW(),"A7")&TEXT(NOW()*0,"")

If you have a mix of values & text, we can handle that with a second UDF:

Public Function TxtOrVal(InTxt As String) As Variant
If Len(InTxt) = 0 Then
TxtOrVal = vbNullString
Exit Function
End If
If Len(Str(Val(InTxt))) < Len(InTxt) Then
TxtOrVal = InTxt$
Exit Function
End If
TxtOrVal = Val(InTxt)
End Function

In A2 (for example) on your summary sheet, you would enter
=TxtOrVal(GetShtVal(ROW(),"A7")&TEXT(NOW()*0,""))

The user-defined functions need to be in a general VBA module in the
workbook where you want this to work. If you are new to user-defined
functions (macros), this link to Jon Peltier's site may be helpful:
http://peltiertech.com/WordPress/200...e-elses-macro/

To learn more about macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Hope this helps,

Hutch

"Eric" wrote:

Thanks for your info, I haven't had chance to try it yet, but I was hoping to
be able to code a cell with something of the order:-
=if(Row()Worksheets.Count,"",Worksheet[Row()]!$A$7)
instead of
='Freds Sheet'!$A$7

Is this a possibility?
--
Eric Hargreaves


"p45cal" wrote:


Sub blah()
NumberOfSheetsToProcess = ThisWorkbook.Sheets.Count - 3 '3 from below
MsgBox NumberOfSheetsToProcess & " sheets to summarise."
For Each sht In ThisWorkbook.Sheets
Select Case sht.Name
Case "Sheet name not to be processed", "Summary", "leaveMeAlone" '
3 here
'do nothing
Case Else
MsgBox "about to process sheet '" & sht.Name & "'"
'do lots of summarising using sht as your way of referencing that
sheet
End Select
Next sht
End Sub


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=127378


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
tabs are missing even though 'tools-options-view-sheet tabs' ok? rgranell Excel Worksheet Functions 3 August 16th 08 04:25 PM
Problem seeing and accessing top of sheet egii Excel Discussion (Misc queries) 1 January 11th 07 02:52 AM
Excel sheet tabs NEstman Excel Discussion (Misc queries) 2 August 23rd 06 10:12 PM
How do I change the Excel sheet tab bar to display more sheet tabs Rockie Excel Discussion (Misc queries) 3 August 18th 06 02:29 PM
excel sheet tabs CQ Excel Discussion (Misc queries) 1 January 26th 05 12:09 AM


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