This page contains some VBA macros. Assistance to Install a Macro or User Defined Function on my Formula page. |
Coding for macros BuildTOC, SortAllSheets, DelHyperLinks, MakeHyperLinks, RunSubFromActiveCell, LinkFix, LinkFix_GoTo, MakeHTML_Link
and the user defined functions URL and MSKBQ can be found at
http://www.mvps.org/dmcritchie/excel/code/buildtoc.txtSeparate coding for ListFunctionsAndSubs can be found at
http://www.mvps.org/dmcritchie/excel/code/listfsubs.txt
See internal note concerning "Microsoft Visual Basic For Application Extensibility" required in the VBEand the macros GoToCell, GoToHyperlink, GoToSheet,
GoToNextSheet,
GoToPrevSheet,
GoToSub, ShowTopLeft and ShowTopLeft5. can be found at
http://www.mvps.org/dmcritchie/excel/code/gotostuff.txt also see Toolbar and Menu examples on Toolbars page.
Creating a Table of Contents with hyperlinks to the sheets in the workbook is simple using the BuildTOC() macro. XL2000 provides hypertext links in your Excel spreadsheets. The links generated here will be to sheets within your workbook.
Included are Worksheet, Module, and Dialog which will be sorted descending so that the worksheets appear first. Sheet Tabs on the otherhand are sorted without regard to type, do not include modules, and the collating sequence is slightly different for special characters such as a tilde (~).
|
Referencing a WorksheetReferencing the Worksheet name seen on the tabs at the bottomWorksheets("Sheet3").Select Sheets("Sheet3").Select Referencing the sheet name (code name) that is located in the sheets properties (in the Properties window) in VBE. Sheet3.Select Sheet(3).Select Referencing the sheet name as the activesheet ActiveSheet.Range("A1").Value = 99 The Table shown on the left is typical of the generated results from the BuildTOC described on this page. |
Although this page is really mainly about hyperlinks. You might find the following formula version interesting. You would see nothing, A5 or A8 which would correspond to no link, link to A5 or link to A8 all depending on value in A1. This is all one long worksheet formula, no spaces needed...
=IF(TRIM(A1)="","",IF(A1<5,HYPERLINK("[vlookup.xls]Sheet31!A5","a5"),HYPERLINK("[vlookup.xls]Sheet31!A8","a8")))
A | B | C | D | E | F | G | |
1 | Select A3 and create or redo with BuildTOC() | ||||||
2 | Worksheet | Type | CodeName | lastcell | cells | scrollarea | Printarea |
3 | Contractors | Worksheet | Sheet5 | T168 | 3,360 | $A$1:$I$168 | |
4 | Insulation | Worksheet | Sheet2 | Y139 | 3,475 | ||
5 | Introduction | Worksheet | Sheet12 | CL946 | 85,140 | ||
6 | Misbehaving | Worksheet | Sheet20 | M65536 | 851,968 | ||
7 | Reporting | Worksheet | Sheet8 | AQ81 | 3,483 | $S$1:$AQ$59 | |
8 | Requirements | Worksheet | Sheet9 | AL93 | 3,534 | ||
9 | Sheet1 | Worksheet | Sheet32 | AP59 | 2,478 | ||
10 | Sub Contract | Worksheet | Sheet11 | AL93 | 3,534 | $A$1:$S$132 | |
11 | Suppliers - ALL | Worksheet | Sheet7 | AC2411 | 69,919 | ||
12 | Suppliers - Major | Worksheet | Sheet10 | AL93 | 3,534 | $1:$65536 | |
13 | Vendor List | Worksheet | Sheet6 | AX1094 | 54,700 | $A1:M79 | $A$1:$Q$79 |
Also have an auxiliary page on how to Build a Summary Sheet for sheets that have exactly the same consistent format.
If you need instructions to install a macro see my formula page.
Update - update - update - update - update - update -
update - update - update - update - update - update.
This macro has been redesigned to work in XL95, XL97, and XL2000.
In XL95 you cannot use hyperlinks but you can use the GoToSheet subroutine included.
Chip Pearson has noted in a newsgroup posting that
having more than a couple of dozen hyperlinks of the object kind can
have a devastating effect on workbook performance. So the BuildTOC macro
has been changed to create the =HYPERLINK(target,description) type instead of
object hyperlinks. Also note that the object hyperlinks can be removed with DelHyperlinks() macro described on this web page.
Update - update - update - update - update - update -
update - update - update - update - update - update.
Sub BuildTOC() 'listed from active cell down 7-cols -- DMcRitchie 1999-08-14 2000-09-05 Dim iSheet As Integer, iBefore As Integer Dim sSheetName As String, sActiveCell As String Dim cRow As Long, cCol As Long, cSht As Integer Dim lastcell Dim qSht As String Dim mg As String Dim rg As Range Dim CRLF As String Dim Reply As Variant Application.Calculation = xlCalculationManual Application.ScreenUpdating = False cRow = ActiveCell.Row cCol = ActiveCell.Column sSheetName = UCase(ActiveSheet.Name) sActiveCell = UCase(ActiveCell.Value) mg = "" CRLF = Chr(10) 'Actually just CR Set rg = Range(Cells(cRow, cCol), Cells(cRow - 1 + ActiveWorkbook.Sheets.Count, cCol + 7)) rg.Select If sSheetName <> "$$TOC" Then mg = mg & "Sheetname is not $$TOC" & CRLF If sActiveCell <> "$$TOC" Then mg = mg & "Selected cell value is not $$TOC" & CRLF If mg <> "" Then mg = "Warning BuildTOC will destructively rewrite the selected area" _ & CRLF & CRLF & mg & CRLF & "Press OK to proceed, " _ & "the affected area will be rewritten, or" & CRLF & _ "Press CANCEL to check area then reinvoke this macro (BuildTOC)" Application.ScreenUpdating = True 'make range visible Reply = MsgBox(mg, vbOKCancel, "Create TOC for " & ActiveWorkbook.Sheets.Count _ & " items in workbook" & Chr(10) & "revised will now occupy up to 10 columns") Application.ScreenUpdating = False If Reply <> 1 Then GoTo AbortCode End If rg.Clear 'Clear out any previous hyperlinks, fonts, etc in the area For cSht = 1 To ActiveWorkbook.Sheets.Count Cells(cRow - 1 + cSht, cCol) = "'" & Sheets(cSht).Name If TypeName(Sheets(cSht)) = "Worksheet" Then 'hypName = "'" & Sheets(csht).Name ' qSht = Replace(Sheets(cSht).Name, """", """""") -- replace not in XL97 qSht = Application.Substitute(Sheets(cSht).Name, """", """""") If Application.Version < "8.0" Then '-- use next line for XL95 Cells(cRow - 1 + cSht, cCol + 2) = "'" & Sheets(cSht).Name 'XL95 Else '-- Only for XL97, XL98, XL2000 -- will create hyperlink & codename Cells(cRow - 1 + cSht, cCol + 2) = "'" & Sheets(cSht).CodeName '--- excel is not handling lots of objects well --- 'ActiveSheet.Hyperlinks.Add Anchor:=Cells(cRow - 1 + cSht, cCol), _ ' Address:="", SubAddress:="'" & Sheets(cSht).Name & "'!A1" '--- so will use the HYPERLINK formula instead --- '--- =HYPERLINK("[VLOOKUP.XLS]'$$TOC'!A1","$$TOC") ActiveSheet.Cells(cRow - 1 + cSht, cCol).Formula = _ "=hyperlink(""[" & ActiveWorkbook.Name _ & "]'" & qSht & "'!A1"",""" & qSht & """)" End If Else Cells(cRow - 1 + cSht, cCol + 2) = "'" & Sheets(cSht).Name End If Cells(cRow - 1 + cSht, cCol + 1) = TypeName(Sheets(cSht)) ' -- activate next line to include content of cell A1 for each sheet ' Cells(cRow - 1 + csht, cCol + 3) = Sheets(Sheets(csht).Name).Range("A1").Value On Error Resume Next Cells(cRow - 1 + cSht, cCol + 6) = Sheets(cSht).ScrollArea '.Address(0, 0) Cells(cRow - 1 + cSht, cCol + 7) = Sheets(cSht).PageSetup.PrintArea If TypeName(Sheets(cSht)) <> "Worksheet" Then GoTo byp7 Set lastcell = Sheets(cSht).Cells.SpecialCells(xlLastCell) Cells(cRow - 1 + cSht, cCol + 4) = lastcell.Address(0, 0) Cells(cRow - 1 + cSht, cCol + 5) = lastcell.Column * lastcell.Row byp7: 'xxx On Error GoTo 0 Next cSht 'Now sort the results: 2. Type(D), 1. Name (A), 3. module(unsorted) rg.Sort Key1:=rg.Cells(1, 2), Order1:=xlDescending, Key2:=rg.Cells(1, 1) _ , Order2:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, _ Orientation:=xlTopToBottom rg.Columns.AutoFit rg.Select 'optional 'if cells above range are blank want these headers ' Worksheet, Type, codename If cRow > 1 Then If "" = Trim(Cells(cRow - 1, cCol) & Cells(cRow - 1, cCol + 1) & Cells(cRow - 1, cCol + 2)) Then Cells(cRow - 1, cCol) = "Worksheet" Cells(cRow - 1, cCol + 1) = "Type" Cells(cRow - 1, cCol + 2) = "CodeName" Cells(cRow - 1, cCol + 3) = "[opt.]" Cells(cRow - 1, cCol + 4) = "Lastcell" Cells(cRow - 1, cCol + 5) = "cells" Cells(cRow - 1, cCol + 6) = "ScrollArea" Cells(cRow - 1, cCol + 7) = "PrintArea" End If End If Application.ScreenUpdating = True Reply = MsgBox("Table of Contents created." & CRLF & CRLF & _ "Would you like the tabs in workbook also sorted", _ vbOKCancel, "Option to Sort " & ActiveWorkbook.Sheets.Count _ & " tabs in workbook") Application.ScreenUpdating = False If Reply = 1 Then SortALLSheets 'Invoke macro to Sort Sheet Tabs Sheets(sSheetName).Activate AbortCode: Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic End Sub Sub BuildTOC_A3() Cells(3, 1).Select BuildTOC End Sub Sub SortALLSheets() 'sort sheets within a workbook in Excel 7 -- Bill Manville 'modified to sort all sheets instead of just worksheets Dim iSheet As Integer, iBefore As Integer For iSheet = 1 To ActiveWorkbook.Sheets.Count Sheets(iSheet).Visible = True For iBefore = 1 To iSheet - 1 If UCase(Sheets(iBefore).Name) > UCase(Sheets(iSheet).Name) Then ActiveWorkbook.Sheets(iSheet).Move Before:=ActiveWorkbook.Sheets(iBefore) Exit For End If Next iBefore Next iSheet End SubObject links cause problems if you have a lot of them. Changing from object links to worksheet hyperlinks opens up it's own can of worms, since the worksheet function requires the workbook name.
If using XL97 or earlier see compatibility notes concerning Replace.
The following suggestion has been made by Dave Peterson (not posted 2001-03-22) who
says that renaming the book messes up such references as:
=HYPERLINK("[VLOOKUP.XLS]'sumproduct'!A1","sumproduct")
Instead of:
ActiveSheet.Cells(cRow - 1 + cSht, cCol).Formula = _ "=hyperlink(""[" & ActiveWorkbook.Name _ & "]'" & qSht & "'!A1"",""" & qSht & """)"Davd Peterson suggests:
myformula = MID(CELL(""filename"",$A$1),FIND(""" _ & "["",CELL(""filename"",$A$1)),FIND(""]""," _ & "CELL(""filename"",$A$1))-FIND(""[""," _ & "CELL(""filename"",$A$1))+1)" ActiveSheet.Cells(cRow - 1 + vis_sht, cCol).Formula = _ "=hyperlink(" & myformula & "&""" _ & "'" & qSht & "'!a1"",""" & qSht & """)"
Sub BuildTOC_A3() Cells(3, 1).Select 'Selects cell A3 BuildTOC End SubTo install the button over a cell with the wording "GoTo/ $$TOC and/ invoke/ BuildTOC".
Each time you run BuildTOC you will rearrange the listing of sheetnames, so if you wanted to include additional information you would need to pull that information in from another sheet or rename of modify the BuildTOC macro.
You could have another sheet and use VLOOKUP, or if the information is in a specific location on the $$TOC indicated sheet use INDIRECT.
You could use INDIRECT and get information off of the indicated sheet.
=INDIRECT("'"'&A11&"'!A1")
-- single quotes are enclosed in double quotes
The above formula might equate to ='sheet1'!A1
You could use VLOOKUP to get associated information from another sheet
=VLOOKUP(A11,table,1,false) i.e. sheetname in column 1 of table
=VLOOKUP(A11,table,2,false) i.e. lastname of person in column 2 of table
False, in VLOOKUP, requires an exact match and the table does not need to be sorted. You do not want to use true because that will return an exact match or an approximate match.
For more information on VLOOKUP see HELP and my vlookup page
VLOOKUP Worksheet Function
Sub SortALLSheets() 'sort sheets within a workbook in Excel 7 -- Bill Manville 'modified to sort all sheets instead of just worksheets Dim iSheet As Integer, iBefore As Integer For iSheet = 1 To ActiveWorkbook.Sheets.Count Sheets(iSheet).Visible = True For iBefore = 1 To iSheet - 1 If UCase(Sheets(iBefore).Name) > UCase(Sheets(iSheet).Name) Then ActiveWorkbook.Sheets(iSheet).Move Before:=ActiveWorkbook.Sheets(iBefore) Exit For End If Next iBefore Next iSheet End Sub
Sub SheetnamesInA1() '2000-04-20 Dim iSheet as Long Application.ScreenUpdating = False For iSheet = 1 To ActiveWorkbook.WorkSheets.Count WorkSheets(iSheet).cells(1,1) = "'" & WorkSheets(iSheet).name Next iSheet Application.ScreenUpdating = True End Sub
Sub trevor001() Dim Cell As Range For Each Cell In Selection ActiveSheet.Hyperlinks.Add Anchor:=Cells(Cell.Row, Cell.Column), _ Address:="", SubAddress:="'" & Sheets(Cell.Value).Name & "'!A1" Next Cell End Sub
Sub SheetNamesAcrossColumns() Dim iSheet As Integer For iSheet = 1 To ActiveWorkbook.WorkSheets.Count ActiveCell.offset(0, iSheet - 1) = WorkSheets(iSheet).Name Next iSheet End SubTo Reference cell $a$4 on the worksheet named in Row 1
=INDIRECT( "'" & D1 & "'" & "!$a$4")those are single quotes enclosed in double quotes to allow use of sheetnames with embedded spaces.
'Display Subroutine or Function named in selected cell Sub GoToSub() 'David McRitchie 1999-11-12 rev. 2000-04-13 'http://www.mvps.org/dmcritchie/excel/buildtoc.htm On Error GoTo notfound 'formerly named GoToSubroutine Dim i As Integer Application.Goto Reference:=ActiveCell.Value Exit Sub notfound: On Error GoTo notfound2 If Left(ActiveCell.Formula, 1) = "=" Then For i = 1 To Len(ActiveCell.Formula) If Mid(ActiveCell.Formula, i, 1) = "(" Then MsgBox Mid(ActiveCell.Formula, 2, i - 2) Application.Goto Reference:=Mid(ActiveCell.Formula, 2, i - 2) Exit Sub End If Next i MsgBox Mid(ActiveCell.Formula, 2, i - 2) _ & "was not found as a User Defined Function, " _ & "verify with Paste Function Wizard [fx]" End If notfound2: On Error Resume Next MsgBox "Procedure or Function " & ActiveCell.Value _ & " is not available, try ALT+F8 to find Sub, or [fx] to find UDF" End SubAs an alternative to GoToSub you can use Alt+F11, then F2 (View, Object Browser), select All Libraries or a specific library such as personal.xls then under classes choose global and look form macro in boldface to the right.
Sub RunSubFromActiveCell() Application.Run ActiveCell.Value End SubExamples of content for Activecell:
Sub GoToSheet() 'David McRitchie On Error Resume Next If Worksheets(ActiveCell.Value) Is Nothing Then MsgBox ActiveCell.Value & " -- sheet does not exist" Else Sheets(ActiveCell.Value).Select End If On Error GoTo 0 End Sub
To select a sheet with a known name in VBA
Application.Goto Reference:=Range("'Radio Stations'" & "!a1")The sheetname is enclosed with single quotes to allow you to code a sheet with spaces in the name, that in turn is surrounded by double quotes.
For a variation of GoToSheet, see GoToCustomerSheet, which uses an input box to ask for a customer which equates to a sheetname.
Summary of possible steps: (Gary Brown)
Workbooks.Open Filename:="C:\Temp\Myfile.xls"
Windows("Myfile.xls").Visible = True
Application.Goto Reference:="sheetaa!C14"
'Active cell repositioned to Top also showing 5 cells to left ' remains on same sheet Sub ShowTopLeft5() Dim caddr As String caddr = Selection.Address Application.Goto Reference:=Cells(ActiveCell.Row, _ Application.WorksheetFunction _ .Max(1, ActiveCell.Column - 5)), Scroll:=True Range(caddr).Select End SubA simpler version just makes the activecell the top left cell.
'repostition active cell to Top Left corner ' remains on same sheet Sub ShowTopLeft() Application.Goto Reference:=Range(ActiveCell.Address), Scroll:=True End Sub
ListFunctionsAndSubs
A | B | C | D | E | F | G | H | |
1 | Book | Module | Name | Type | Beg# | Lns | ### | chk |
2 | testng2k.xls | Module4 | AltRowDelete | SubRoutine | 35 | 8 | 132 | |
3 | personal.xls | Module1 | auto_Open | SubRoutine | 1 | 7 | 1 | Dup |
4 | testng2k.xls | Module1 | auto_open | SubRoutine | 2 | 13 | 24 | Dup |
5 | testng2k.xls | Module19 | Beep2 | SubRoutine | 7 | 34 | 155 | |
6 | testng2k.xls | Module13 | GetCellFormat | SubRoutine | 18 | 11 | 142 | |
7 | personal.xls | Module1 | GetFormat | Function | 31 | 6 | 5 | Dup |
8 | testng2k.xls | ModuleF | GetFormat | Function | 24 | 6 | 71 | Dup |
9 | personal.xls | Module1 | MarkSepAreas | SubRoutine | 72 | 14 | 12 | |
10 | testng2k.xls | Module1 | Upper_Case | SubRoutine | 70 | 15 | 29 | |
11 | personal.xls | Module1 | UseFormula | Function | 8 | 6 | 2 | Dup |
12 | testng2k.xls | ModuleF | UseFormula | Function | 1 | 6 | 68 | Dup |
13 | testng2k.xls | Module1 | XL2HTML | SubRoutine | 174 | 54 | 35 | |
14 | testng2k.xls | mod.XL2HMLx | XL2HTMLx | SubRoutine | 8 | 97 | 166 |
Separate coding for ListFunctionsAndSubs can be found here, references to similar material can be found in the Related area of this page, such as Chip Pearson's "Coding for the VBE".
A companion piece of code that is used, since I could not establish hyperlinks to subroutines and functions within the VBA editor, and it is shown below and can be assigned to a single button. You may select any cell on the row to get to the code. Be forewarned that each time you invoke the subroutine another window page is stored so you might want to use the little [x] to get out of that code module each time (not talking about the big [X] to get out of the VBA editor. ShowSubOrFunction is specialized to this table see GoToSub for a more generic macro.
Sub ShowSubOrFunction() '--Companion to ListFunctionsAndSubs, for lack of a hypertext solution. '--Application.Goto Reference:=WBName & "!" & Subname Application.Goto Reference:=Cells(ActiveCell.Row, 1).Value _ & "!" & Cells(ActiveCell.Row, 3).Value End Sub
Didn't have a chance to look at this posting 2002-03-08 by Myrna, I think it extracts codes from Add-Ins, if so, could be used to include add-in functions.
A | B | C | D | E | F | G | H | |
1 | WORKBOOK: LISTSUBS.XLS, 7 Sep 1999 | |||||||
2 | Module | ModType | Priv? | Procedure Name | Type | Priv? | Parms? | Line # |
3 | ListSubsCode | Std | ListProcedures | Sub | 44 | |||
4 | ListSubsCode | Std | GetProcedures | Sub | X | X | 161 | |
5 | ListSubsCode | Std | ModuleIsPrivate | Function | X | X | 282 | |
6 | ListSubsCode | Std | ReadTheLine | Sub | X | X | 298 | |
7 | ListSubsCode | Std | GetProcedureInfo | Sub | X | X | 320 | |
8 | ListSubsCode | Std | NextWord | Function | X | X | 420 |
A | B | C | D | E | F | |
1 | Description | Name | GUID | #Major | #Minor | Path |
2 | Visual Basic For Applications | VBA | {000204EF-0000-0000-C000-000000000046} | 4 | 0 | C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL |
3 | Microsoft Excel 9.0 Object Library | Excel | {00020813-0000-0000-C000-000000000046} | 1 | 3 | C:\Program Files\Microsoft Office\Office\EXCEL9.OLB |
4 | OLE Automation | stdole | {00020430-0000-0000-C000-000000000046} | 2 | 0 | C:\WINDOWS\SYSTEM\stdole2.tlb |
5 | Microsoft Office 9.0 Object Library | Office | {2DF8D04C-5BFA-101B-BDE5-00AA0044DE52} | 2 | 1 | C:\Program Files\Microsoft Office\Office\MSO9.DLL |
Sub EnumerateSheets_XL95() 'listed from active cell down 2-cols -- DMcRitchie 1999-03-04 Application.Calculation = xlManual 'xl97 up use xlCalculationManual Application.ScreenUpdating = False cRow = ActiveCell.Row cCol = ActiveCell.Column For csht = 1 To ActiveWorkbook.Sheets.Count 'worksheet or sheets Cells(cRow - 1 + csht, cCol) = "'" & Sheets(csht).Name Cells(cRow - 1 + csht, cCol + 1) = TypeName(Sheets(csht)) '-- include next line if you want to see cell A1 for each sheet Cells(cRow - 1 + csht, cCol + 2) = Sheets(Sheets(csht).Name).Range("A1").Value Next csht Application.ScreenUpdating = True Application.Calculation = xlAutomatic 'xl97 up use xlCalculationAutomatic End SubSimilar to the above. Exceptions: uses OFFSET. Populates with the A1 cell from each worksheet.
Sub GetAllA1Cells() Application.ScreenUpdating = False 'DMcRitchie 2000-10-24 Application.Calculation = xlCalculationManual Dim iSheet As Integer For iSheet = 1 To ActiveWorkbook.Worksheets.Count ActiveCell.Offset(iSheet - 1, 0) = Worksheets(iSheet).[a1].Value ActiveCell.Offset(iSheet - 1, 1) = "'" & Worksheets(iSheet).Name Next iSheet Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub
Sub Build_SS_Button() 'Build button on spreadsheet to invoke macro 'adapted from a posting by "Jim/Nospam" on 30Aug1999 ActiveCell.Select Selection.Copy ActiveSheet.Pictures.Add(251, 88, 75, 13).Select Selection.Interior.ColorIndex = 8 Application.CutCopyMode = False Selection.OnAction = ActiveCell.Value 'Macro to be invoked End SubTo remove a button created as above, RtClick/Cut
To create a button on toolbar see my page -- Toolbars and Custom Buttons
'Show names of sheets in pop-up (same as Rclick on TabNav keys) -- Jim Rech CommandBars("Workbook tabs").ShowPopup 'Rename current Sheet - Tom Oglivy Application.Dialogs(xlDialogWorkbookName).ShowCode to check if an add-in is still active, if not, to reactivate it. Also see EnumerateAddins to create a list of addins.
If AddIns("Autosave Add-in").Installed = False Then AddIns("Autosave Add-in").Installed = True MsgBox "autosave add-in reset back to True" End If
A similar problem is attempting to enter a formula into the formula bar and getting interference from cell addresses popping into the formula caused by backspacing or cell selecting when trying to key in the formula is to press the F2 beforehand.
Believe this is working now 2000-02-13 after minor tuneup
Actually the extraction from the hyperlink is just an approximation.Function URL(cell As Range) 'Tom Ogilvy, programming 1999-04-14 Deja: AN=468281862 'Chip Pearson, programming 1999-04-14 Deja: AN=468345917 'David McRitchie, combined 1999-11-13 'cannot process imbedded link to internal sheet yet ... Application.ScreenUpdating = False If Trim(cell.Formula) = "" Then URL = "" Exit Function End If ' 1234567890122 If Left(UCase(cell.Formula), 11) = "=HYPERLINK(" Then If Left(UCase(cell.Formula), 12) = "=HYPERLINK(""" Then URL = Mid(cell.Formula, 13, InStr(1, cell.Formula, ",") - 13) Exit Function 'next part for nonquoted first parm End If URL = Mid(cell.Formula, 12, InStr(1, cell.Formula, ",") - 12) Exit Function End If URL = "" On Error Resume Next URL = cell.Hyperlinks(1).Address If URL = 0 Then URL = "'**" Application.ScreenUpdating = True End FunctionThis one works for hyperlinks as hyperlinks not =HYPERLINK(...)
So use the URL function above.Function HyperlinkAddress(cell) On Error Resume Next HyperlinkAddress = cell.Hyperlinks(1).Address if hyperlinkaddress = 0 then hyperlinkaddress = "" End FunctionIf you change the object hyperlink without reentering it the Function will not show the updated value when changed or when recalculated [F9] until a complete recalculation is performed [Ctrl+Alt+F9]<a href="http://www.nbc.com/" title="NBC Channel 4 in New York city">NBC</a>
ActiveSheet.Hyperlinks.Add Anchor:=Range("C22"), Address:= _ "http://www.nbc.com/", ScreenTip:="NBC Channel 4 in New York city", _ TextToDisplay:="NBC" Function HyperlinkScreenTip(cell) On Error Resume Next HyperlinkScreenTip = cell.Hyperlinks(1).ScreenTip If HyperlinkScreenTip = 0 Then HyperlinkScreenTip = "" End FunctionAlthough it would be redundant you could have a subroute to show TextToDisplay.
The following macro will delete such hyperlinks from the selected area. It will not delete those you create with =HYPERLINK(..) formula.
Sub DelHyperLinks() Selection.Hyperlinks.Delete End SubFor the really spitefull who wish to unconditionally obliterate all hyperlinks: (ctrl+a before the above would be just as effective) Sub DelAllHyperlinks() ActiveSheet.HyperLinks.Delete End Sub See the related area for the complicated means of automatically removing hyperlinks. For those with Excel XL (Excel 2002) you can suppress hyperlink generation under the Auto Correct from the Tools menu.
The opposite of this is Creating Hyperlinks for all Cells in a Selection
To select all hyperlinks (not formula hyperlinks) in a selection
Sub SelectHyperlinks() 'D.McRitchie 2001-01-24 buildtoc.htm Dim hl As Variant Dim rng1 As String For Each hl In ActiveSheet.Hyperlinks rng1 = rng1 & "," & hl.Parent.Address(0, 0) Next hl If rng1 = "" Then MsgBox "No Hyperlinks found in Sheet, so none in selection" Exit Sub End If rng1 = Right(rng1, Len(rng1) - 1) On Error Resume Next Intersect(Selection, Range(rng1)).Select If Err.Description = "" Then Exit Sub MsgBox "Change your initial selection" & Chr(10) & _ "there are hyperlinks, but none in you initial selection" _ & Chr(10) & Err.number & " " & Err.Description End Sub
If you want do delete links (I think selectively) see Find Links by Bill Manville in the MVP area of Steve Bullen's site. To prevent creation of selected hyperlinks see Q233073 it is an Event macro that will be invoked each time a link is changed.
Sub ConvertHyperlinks() 'David McRitchie, misc, 2000-01-17, misc 'http://www.mvps.org/dmcritchie/excel/buildtoc.htm Dim cell As Range Dim hyperlinkaddress As String, hyperlinkformula As String For Each cell In Selection On Error GoTo skipHyper hyperlinkaddress = cell.Hyperlinks(1).Address On Error GoTo 0 If hyperlinkaddress = "" Then GoTo skipHyper hyperlinkformula = cell.Formula If Left(hyperlinkformula, 1) = "=" Then hyperlinkformula = Right(hyperlinkformula, Len(hyperlinkformula) - 1) Else hyperlinkformula = Replace(hyperlinkformula, """", """""") hyperlinkformula = """" & hyperlinkformula & """" End If cell.Formula = "=HYPERLINK(""" & hyperlinkaddress & _ """," & hyperlinkformula & ")" skipHyper: On Error GoTo 0 Next cell On Error GoTo 0 Selection.Hyperlinks.Delete For Each cell In Selection cell.Formula = cell.Formula Next cell End SubSee note on compatibility Replace not available in Excel 97.
If you do remove the hyperlinks you could use this method to get to the displayed link, expect this would also work for XL95 but not sure. Also see GoToHyperlinkSub GoToHTML() 'David McRitchie, 2000-12-13 'documented in http://www.mvps.org/dmcritchie/excel/buildtoc.htm 'selected cell contains http://www.abcexample.com On Error Resume Next If Len(Trim(ActiveCell.Value)) = 0 Then Exit Sub ActiveWorkbook.FollowHyperlink Address:=ActiveCell.Value, _ NewWindow:=False, AddHistory:=True If Err.number <> 0 Then MsgBox Err.number & " " & Err.Description & Chr(10) & _ "Tried to bring up file in " & ActiveCell.Address(0, 0) & _ Chr(10) & ActiveCell.Text End If 'Application.WindowState = xlNormal -- what would this do? End SubThe following will take the hyperlink, if it fails you can paste the failed hyperlink into a Find dialog where used.Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Dim MyDataObj As New DataObject Dim pLnk As String pLnk = Trim(ActiveCell.Value) On Error GoTo Failure MyDataObj.SetText pLnk On Error Resume Next MyDataObj.PutInClipboard Failure: GoToHTML '-- or GoToHyperlink (also seen on this page) ActiveCell.Interior.ColorIndex = 20 End Sub
Sub MakeTextOnlyFromHyperlinks() 'David McRitchie, 2000-08-23 worksheet.functions !! Dim cell As Range Dim URL As String For Each cell In Selection If IsEmpty(cell) Then GoTo chknext MsgBox cell.Address URL = "" On Error Resume Next URL = cell.Hyperlinks(1).Address If Err.Number = 9 Then GoTo chknext If Trim(URL) = "" Then GoTo chknext cell.Value = URL cell.Hyperlinks(1).Delete chknext: On Error GoTo 0 Next cell End Sub
A B C 1 Site =GetFormula(Bn) 2 ABC X =IF(A2="","",HYPERLINK("http://www." & A2 & ".com","X")) 3 Microsoft X =IF(A3="","",HYPERLINK("http://www." & A3 & ".com","X")) 4 NBC X =IF(A4="","",HYPERLINK("http://www." & A4 & ".com","X")) 5 NBCi X =IF(A5="","",HYPERLINK("http://www." & A5 & ".com","X")) Besides the obvious advantage of creating Hyperlinks on the fly, is that you can easily change column A without having to use keyboard tricks to avoid taking the link when changing the sites.
The URL formula described on this page will not work on the HYPERLINK formulas shown above.
Worksheet code that created a hyperlink
=HYPERLINK("h:\excel2k\testng2k.xls#sheet3!a1","SHEET3") =HYPERLINK("[h:\excel2k\testng2k.xls]sheet3!a1","SHEET3") =HYPERLINK("[d:test\test.xls]test!b5","thisone good b5") =HYPERLINK("d:\website\dmcritchie","dmcr") =HYPERLINK("d:test\test.xls","thisone is also good") =HYPERLINK("[testng2k.xls]'$$TOC'!A56","heidi-ho $$TOC!A56") =HYPERLINK("[h:\excel2k\testng2k.xls]'$$TOC'!a3","text in a3 in $$TOC") =HYPERLINK("[file:\\\d:test\test.xls]test!B3","thisone is good") =HYPERLINK("[http://www.business.com/report/budget report.xls]Annual!F10","Report") =HYPERLINK("[vlookup.xls]'sheet"&F2&"'!a4","sheet"&F2) -- using a cell =HYPERLINK("[vlookup.xls]'sheet"&ROW()+38&"'!a4","sheet"&ROW()+38) -- cell and sequence =HYPERLINK("[http://www.mvps.org/dmcritchie/excel/excel.htm]","My Excel Pages") =HYPERLINK("file:\\\c:\temp\David McRitchie\a.txt","thisone is good")It appears that even if the link is to a cell in the same worksheet you must include the bookname including .XLS extension, as well as the sheetname.=HYPERLINK("[WBName.xls]Michael!A5", "Michael I")
As aready mentioned you must include the filename, even if it refers to a cell in the same workbook. You can use this code to generate the workbook name. As mentioned on my Pathname page you must include the cell reference to get a valid result from the CELL Worksheet Function.B3: =MID(CELL("filename",A1),FIND("[",CELL("filename",A1),1)+1,FIND("]",CELL("filename",A1),1)-FIND("[",CELL("filename",A1),1)-1)
and use it as follows:
A1: =HYPERLINK("["&hyperlink!$B$3 & "]'Sheet One'!A1","Sheet One")
programming version
See URL function above. Examine formula instead for those entered as HYPERLINK(...)URL = ActiveCell.Hyperlinks(1).Address 'see note on HYPERLINK URL_Display = ActiveCell.valueUsing the URL function on the Worksheet
Using the User Defined Function to obtain the link address:
=URL(D4)
=personal.xls!URL(D4)
Using a Worksheet Function to obtain the text value
=D4When using a function that exists in a different workbook, include the workbook name as shown above, failure to find your function will result in an error -- #NAME?
In XL2000 if you type an email address (or something that looks like one) you can hit UNDO (ctrl+z) and the link portion will disappear along with the font formatting of a link.
When the link has been established typing into the cell will not affect the link, unless what you type is another hyperlink, which will create the link (in this case replace) in the normal fashion.
I also noticed that while recording a macro that typing in an email address
DMcRitchie@msn.com will NOT create a hyperlink, but once I stop recording, the email address link will be created. (maybe someone has an explanation for this -- XL2000).
=Hyperlink("mailto:DMcRitchie@msn.com","David McRitchie")TCP/IP Transmission Control Protocol/Internet Protocol (Internet)
=Hyperlink("telnet://" & A1,A1)
Sub single_hyp() ActiveSheet.Hyperlinks.Add Anchor:=ActiveCell, Address:=ActiveCell.Value End Sub
Sub MakeHyperlinks() Dim cell As Range For Each cell In Selection With Worksheets(1) .Hyperlinks.Add Anchor:=cell, _ Address:=cell.Value, _ ScreenTip:=cell.Value, _ TextToDisplay:=cell.Value End With Next cell End SubFor a better solution see MakeHyperLinkFormulas", which creates hyperlinks with the HYPERLINK formulas.
Based on MakeHyperlinks above but created separately. "mailto:" will be prefixed in creating the hyperlink.Sub MakeEmailLink() Dim cell As Range Dim i As Integer For Each cell In Selection If InStr(1, cell, "@") > 0 Then With Worksheets(1) .Hyperlinks.Add Anchor:=cell, _ Address:="mailto:" & cell.Value, _ ScreenTip:=cell.Value, _ TextToDisplay:=cell.Value End With End If Next cell End SubFor a better solution see MakeHyperLinkFormulas", which creates hyperlinks with the HYPERLINK formulas.
Object type hyperlinks can lead to performance problems. The following will create HYPERLINK formulas less prone to problems and will combine the functionality of both of the previous macros. The @-sign will be used to determine email addresses, which is not always a perfect choice, so it comes down to knowing both your data and your macro usage.Sub MakeHyperlinkFormulas() Dim cell As Range Dim hyperlinkaddress As String, hyperlinktext As String For Each cell In Selection hyperlinkaddress = Trim(cell.Text) hyperlinktext = Trim(cell.Text) If hyperlinktext = "" Then GoTo skipit If hyperlinktext <> "" Then If InStr(1, hyperlinkaddress, "@") Then If LCase(Left(hyperlinkaddress, 7)) <> "mailto:" Then hyperlinkaddress = "mailto:" & hyperlinkaddress End If Else if Instr(1,hyperlinkaddress,".") = 0 then goto skipit If LCase(Left(hyperlinkaddress, 7)) <> "http://" Then hyperlinkaddress = "http://" & hyperlinkaddress End If End If cell.Formula = "=HYPERLINK(""" & hyperlinkaddress & _ """,""" & hyperlinktext & """)" skipit: Next cell End SubTo opposite of this is to delete all hyperlinks in selection, see DelHyperlinks above.
RtClick on cell --> Edit hyperlink --> [Screen Tip] change the screen tip using the [Screen Tip] button, hit OK (not the [X] on the way out) both to the screen tip dialog and the hyperlink dialog on the way out. The generated code looks something like: Selection.Hyperlinks(1).ScreenTip = "ccccc"
Modules marked Option Private Module can be invoked but will not show up in the menu ALT+F8, though they can be typed in and executed using RUN on the menu, or placed wherever a macro can be assigned.
Coding for personal functions (Function) can be located from the VBA editor (Alt+F11) using F2 to get to the Object Browser. Make sure the first entry "Globals" is selected then look for you functions in boldface next the green boxes interspersed with names and VBA constants.
The [fx] button (Paste Function Wizard dialog box) shows groups of functions including a list ALL functions (near top), the disliked most recently used (at the top), and the User defined functions (near the bottom) of the dialog box on the left-side. The functions in the selected grouping appear in the right-side window.
Using the [=] button to left of the formula bar shows the most recently used functions. If you look at bottom it says "Other functions" select that and you get the Paste Function dialog box that you get with the [fx] button.
Sub forcelinks() Dim xlink As String Dim cell As Range For Each cell In Selection xlink = cell.Value If Left(xlink, 1) = "\" Then xlink = "C:" & cell.Value cell.Formula = "=HYPERLINK(""" & xlink _ & """,""" & xlink & """)" Next cell End Sub preference of using: cell.Formula = "=HYPERLINK(""" & xlink _ & """,""" & xlink & """)" instead of: ActiveSheet.Hyperlinks.Add Anchor:=cell, Address:=xlink, _ TextToDisplay:=xlinka better alternative would be to enter a formula for HYPERLINK:
Application.Goto Range("A1000"), True 'Equivalent usage to those below 'selected cell contains Sheet1!Z100 ' goto indicated sheet and cell, scroll to display cell in top left corner Sub GoToHyperlink() Application.Goto Reference:=Range(activecell.value), Scroll:=True End Sub 'reposition to address in activecell on sheet named to left of cell ' i.e. cell to left of selected cell contains Sheet1, selected cell contains Z100 Sub myHyperlink2() Application.Goto Reference:=Range(ActiveCell(1, 0).Value _ & "!" & ActiveCell.Value), Scroll:=True End Sub
=HYPERLINK("http://www.mvps.org/dmcritchie/excel/excel.htm","My Excel Pages") My Excel Pages in a cell then RClick --> hyperlink http://www.mvps.org/dmcritchie/excel/excel.htm Sub Macro3() Range("D26").Select ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _ "http://www.mvps.org/dmcritchie/excel/excel.htm", _ TextToDisplay:="My Excel Pages" End
'repostition active cell to Top Left corner ' remains on same sheet Sub ShowTopLeft() Application.Goto Reference:=Range(ActiveCell.Address), Scroll:=True End Sub 'Active cell repositioned to Top also showing 5 cells to left ' remains on same sheet Sub ShowTopLeft5() Dim caddr As String caddr = Selection.Address Application.Goto Reference:=Cells(ActiveCell.Row, _ Application.WorksheetFunction _ .Max(1, ActiveCell.Column - 5)), Scroll:=True Range(caddr).Select end Sub
Sub GotoWebsite() Dim Link As String Link = "http://www.j-walk.com/ss/excel/tips/tip71.htm" 'address is the origin og this code! On Error GoTo NoCanDo ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True Exit Sub NoCanDo: MsgBox "Cannot open " & Link End Sub before this you have to set reference to Microsoft Word object library in "Tools > References" in the VB editor: Sub OpenWordDocument() Dim wrdApp As Word.Application Set wrdApp = CreateObject("Word.Application") wrdApp.Visible = True wrdApp.Documents.Open ("C:\Temp\Textfile.txt") Set wrdApp = Nothing End Sub
End of topic: Navigating within a Sheet, begin new navigation topic.
ActiveSheet.Previous.Select ActiveSheet.Next.Select Sheets("Sheet1").SelectSubroutines navigating to the Next and Previous sheets can be seen as
One advantage to a web page is that corrections and updates can be made, even though I had checked shortcut keys (XL 95) (XL 2000) and thought there were none for this, I found them later. I like my short cut buttons to navigate backward or forward through the worksheet tabs but there are two shortcut keys that do the same thing.
CTRL+PAGE DOWN Move to the next sheet in the workbook CTRL+PAGE UP Move to the previous sheet in the workbook
A reply post from Myrna Larson to provide for going back to the last viewed sheet <404ftsg4gk02rbi0l2t9hcqj4h5c6sh1f5@4ax.com>
Unsorted selectable list of sheets, RClick on any of the direction arrows to left of sheet TABs, this will pop up an unsorted list of sheets, for a scrollable list goto bottom. This tip is repeated under Related - Alternatives at end of this web page.
The equivalent in VBA (Jim Rech): CommandBars("Workbook tabs").ShowPopup
Creating your own menu with all sheets found in Open Workbooks by Workbook, in a solution posted by Chip Pearson. AN=683847198
Sub GoToCustomerSheet() 'David McRitchie 2000-07-15 excel.programming Dim WantedSheet As String WantedSheet = InputBox("Please Supply Customer Name" _ & Chr(10) & "This should match a sheetname", _ "Specify Customer") If WantedSheet = "" Then Exit Sub On Error Resume Next 'to goto a cell you still need to slect the sheet first Sheets(WantedSheet).Select Sheets(WantedSheet).Range("B14").Select 'Optional If Err = 9 Then 'actually is subscript out of range MsgBox "Your worksheet was not found use RClick on " _ & "Sheet Tab Navigation arrow in lower left corner " _ & "to find desired sheetname." End If End Sub
If you were interested in the currently grouped sheets you could modify code to use
For Each sht In _ Application.ActiveWorkbook.Windows(1).SelectedSheetsinstead of
For csht = 1 To ActiveWorkbook.Sheets.Count 'worksheet or sheets Cells(cRow - 1 + csht, cCol) = "'" & Sheets(csht).NameThe use of the array below would prevent sheet insertion/deletion or reselection of sheets during the running of the macro from causing problems.
Option Explicit Sub AllWorkSheets() Dim Arr() As String Dim I As Integer ReDim Arr(Worksheets.Count) Arr(0) = Worksheets.Count For I = 1 To Worksheets.Count Arr(I) = Worksheets(I).Name Next I For I = 1 To Arr(0) Sheets(Arr(I)).Select Application.Run "pesonal.xls!MarkCells" Next I End SubChange section of code above to process only Selected sheets
Dim sh As Worksheet I = ActiveWorkbook.Windows(1).SelectedSheets.Count ReDim Arr(0 To I) Arr(0) = I I = 1 For Each sh In ActiveWorkbook.Windows(1).SelectedSheets Arr(I) = sh.Name I = I + 1 Next sh
more on sheetnames in an array see http://www.cpearson.com/excel/excelM.htm
Hyperlinks come in two varieties in XL97 and up, and are not available in either variety before XL97.Embedded hyperlinks that you create by Right clicking on a cell and inserting a hyperlink create an object.
HYPERLINK Worksheet Formula is the other. You can see both in my build.htm page, but mainly of the hyperlink object variety and programmed.
Since Chip Pearson has indicated that embedded hyperlinks can cause problems they add to the number of objects in your workbook, and that the formula hyperlinks do not cause problems, would suggest sticking to the Worsheet Functions variety, which you can include as a formula in programming, and double any internal quotes.
see F1 (HELP) --> Index --> HYPERLINK Worksheet Function(see examples on my Worksheet, VBA and Worksheet coding (sheets.htm) page.
Bookmarks, Favorites, My Places, Most Recently Used files
Bookmarks or Favorites into a Spreadsheet
Incidentally you can paste your Internet Explorer Favorites (bookmarks) into an Excel spreadsheet. File, Export, Favorites. create the (HTML) file, select the HTML which is really the Netscape bookmark format (select ALL), and paste into a worksheet. But you can read all about that on my pages. including how to extract the URL from the hyperlinks. If you have the old Netscape 3.2 you sort the bookmarks and reinstall them as Favorites rather than the absurd limitations that you have in IE and in Netscape also now in order to be compatible, I guess. If you begin your favorites foldernames with a space and not your webpages, this will work out nicely (sorting with Netscape 3.2). Update on Bookmarks: Netscape 6.0 will sort bookmarks temporarily. Windows 2000 provides sorted bookmarks under favorites whereever seen, including with IE 6.0, also only temporary as an Export will not be an alphabetical order (folders first, then files). IE 6.0 does not provide sorted bookmarks itself (i.e. not in Win98).Most Recently Used Files
Excel 2000 provides up to 9My Places
Q282087 -- OFFXP: How to Customize the My Places Bar in "Open" and "Save As" Dialog BoxesRemove CRLF characters from ClipBoard
Came up in a discussion in misc group concerning using the notepad to remove CRLF characters when addresses get splitup between lines in newsgroup postings. This can also be done in VBA, though I doubt that you would actually experience this as much of problem within Excel. LinkFix simply remove CRLF; whereas, LinkFix_GoTo will remove CRLF and take you to the link. I have included separate replacement for CR and LF since UNIX machines don't produce CRLF to split lines.
Sub LinkFix() ' Dana DeLouis 2001-03-19 misc, using an ' Idea From: Chip Pearson ' http://www.cpearson.com/excel/clipboar.htm '= = = = = = = = = ' VBA Lib.Ref.: Microsoft Forms 2.0 object lib. ' Excel 2000 due to Replace() Function. '= = = = = = = = = Dim MyDataObj As New DataObject MyDataObj.GetFromClipboard Dim nLnk As String sLnk = Replace(MyDataObj.GetText, _ vbCr, vbNullString) sLnk = Replace(sLnk, vbLf, vbNullString) sLnk = Replace(sLnk, vbLf, vbNullString) sLnk = Replace(sLnk, ">", vbNullString) sLnk = Replace(sLnk, " ", vbNullString) sLnk = Replace(sLnk, Chr(160), vbNullString) MyDataObj.SetText sLnk MyDataObj.PutInClipboard Set MyDataObj = Nothing End Sub | Sub LinkFix_GoTo() ' Dana DeLouis 2001-03-19 misc, ' Dave Peterson, added FollowHyperlink ' Idea From: Chip Pearson ' www.cpearson.com/excel/clipboar.htm '= = = = = = = = = ' VBA Library Reference: ' Microsoft Forms 2.0 object lib. ' Excel 2000 due to Replace() Function. '= = = = = = = = = Dim MyDataObj As New DataObject Dim lnk As String On Error Resume Next MyDataObj.GetFromClipboard lnk = Replace(MyDataObj.GetText, _ vbCrLf, vbNullString) Set MyDataObj = Nothing ActiveWorkbook.FollowHyperlink _ Address:=lnk, NewWindow:=True End Sub |
See note on compatibility Replace not available in Excel 97. |
Replace was not available in Excel 97 so for XL97 you would have to use Excel Substitute instead of VBA Replace. i.e.' qSht = Replace(Sheets(cSht).Name, """", """""") -- replace not in XL97 qSht = Application.Substitute(Sheets(cSht).Name, """", """""")
Sorted selectable list of Subroutines, Tools --> Macros; or Alt+F8, allows running or Editing of subroutine.
Sorted nonselectable list of Subroutines & dialogs, File --> Properties --> contents
Sorted list of Functions, use function wizard or paste function wizard [fx] --> User Function, shows syntax, can show help if available, but does not provide a path to view code.
Populating a ListBox with Sheetnames: AN=582002850
to select: also see Tom Ogilvy Feb 13 2000 in programming *******
My own major categories are: selected high use individual macros, followed by
categories of macros:
Create Test Data, Documentation (footings), Documentation Set, HTML creation,
Information, Rearrange Data on Another Sheet, Reformat
Also note the alphabetical arrangement.
Dim mnbNew As Menu Set mnbNew = MenuBars(xlWorksheet).Menus.Add("&Options") mnbNew.MenuItems.Add "Run &Utility", "Show_Form" mnbNew.MenuItems.Add "-"More complete examples can be found in the Menu links above, and in the macros within John's "Menu Maker".
Build a Summary Sheet for sheets that have exactly the same consistent format. I realized that my Build Table of Contents (this page) is more oriented to the mechanics of maintaining a workbook. Building a Summary Sheet relates more to actual usage and ease of maintaining a summary sheet.
The listing created by BuildTOC has been sorted to make it easy to find each sheet. The SortALLsheets macro is included above.
Gary Brown gives you a choice of ascending or descending sorts and has rehidden the hidden sheets both of which you normally don't see. In fact I don't recall seeing provision for either in previously posted solutions -- guess I just don't like hidden things, and was delighted that unhiding hidden sheets was a byproduct of other solutions, and may not be production oriented to those who hid them in the first place -- here is Gary's code for WorksheetSort() <ejxjzW39$GA.276@cppssbbsa05>.
Not related to anything on this page but the word hidden, to make sure all rows are not hidden you can use something like:
Worksheets("My First Sheet").Rows.Hidden=False
Other sorts: Sorting Sheets in a Workbook, also see Q105069.
Making a TOC in MS Word is described in Woody's Office Watch (28 July 1999, Vol 4 No 31), you can also make an Index but you'll have to look in Help.
EnumerateAddIns() List the add-ins into an "AddinsSheet" in your workbook. (Example).
See Toolbars and Custom Buttons.
Related tips from John Walkenbach's site, concerning menus and sheets:
Related pages on Chip Pearson's site
Create a file showing cell comments in a book, and view results with your web browser.
Faceid,
John Green has a CBlist addin in the MVP area of Steve Bullen's site, to create into empty sheets: 1) list of command bars with it's listable controls (Caption, Type, Face Image, Faceid), 2) Face Images and Faceids, 3) command bars and buttons (subset of 1).
Fonts (fontlist),
Steve Bullen has a GetFonts.zip on his site to list the Windows installed fonts.A listing of fonts using HTML provides a faster approach. http://www.bitstorm.org/fontlist/
Printers
Q166008 - ACC: Enumerating Local and Network Printers
http://support.microsoft.com/support/kb/articles/q166/0/08.asp
Sheets and Cell, addressing, reference
Sheets and Cells
Other Documentation, or Organization Information.
Please send your comments concerning this web page to: David McRitchie mailto:DMcRitchie@msn.com.