Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Needed a function that finds the Workbook level names
that are in a specified sheet and have put something together, but have a feeling that there is a better (less code) way to handle this: Function GetSheetNamedRanges(oSheet As Worksheet) As Variant 'this picks up workbook names that are in the specified sheet 'will need to test for no names found in specified sheet by doing: 'If IsArray(arr) Then '----------------------------------------------------------------- Dim i As Long Dim na As Name Dim rngSheet As Range Dim collNames As Collection Dim arrNames If ActiveWorkbook.Names.Count 0 Then With oSheet Set rngSheet = .Range(.Cells(1), .Cells(.Rows.Count, Columns.Count)) End With Set collNames = New Collection On Error Resume Next For Each na In ActiveWorkbook.Names If Not Application.Intersect(rngSheet, Range(na.Name)) Is Nothing Then If Err.Number = 0 Then collNames.Add na.Name i = i + 1 Else Err.Clear End If End If Next na If i 0 Then ReDim arrNames(1 To i) For i = 1 To i arrNames(i) = collNames(i) Next GetSheetNamedRanges = arrNames End If End If End Function Any suggestions to improve on this? RBS |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
sheet names displayed in first workbook sheet help | Excel Programming | |||
Find and Replace Sheet names | Excel Discussion (Misc queries) | |||
Using Sheet names & Workbook names in VBA coding | Excel Programming | |||
Run macro to find names on seperate workbook, then add info from t | Excel Discussion (Misc queries) | |||
how do I find names in a workbook full of names | Excel Discussion (Misc queries) |