Sub Create_Named_Ranges_List()
Dim rnOmrade As Range
Dim nNamn As Name
Dim lnNamn As Long, lnAntal As Long
Dim Y As Range
'************************************
' first verif is there are active names
'************************************
lnAntal = 0
For Each nNamn In ActiveWorkbook.Names
lnAntal = lnAntal + 1
Next nNamn
If lnAntal = 0 Then
MsgBox "Could not find any names", vbInformation, "Create Namelist"
Exit Sub
End If
Application.DisplayAlerts = False
On Error Resume Next
ActiveWorkbook.Sheets("Namelist").Delete
ActiveWorkbook.Sheets.Add
On Error GoTo 0
'********************************
' set columns names *
'********************************
With ActiveSheet
.Name = "Namelist"
.Cells(1, 1).Value = "Name:"
.Cells(1, 2).Value = "Value:"
.Cells(1, 3).Value = "Refer to:"
.Cells(1, 4).Value = "cell1:"
.Cells(1, 5).Value = "cell2:"
.Cells(1, 6).Value = "Start:"
.Cells(1, 7).Value = "End:"
With .Range("A1:G1")
.Font.Bold = True
.Font.ColorIndex = 10
.Font.Size = 10
End With
End With
lnNamn = 2
For Each nNamn In ActiveWorkbook.Names
If nNamn.Name Like "*!Print_*" Then GoTo Fortsatt
ActiveSheet.Cells(lnNamn, 1).Value = nNamn.Name
ActiveSheet.Hyperlinks.Add _
Anchor:=ActiveSheet.Cells(lnNamn, 1), _
Address:="", _
SubAddress:=nNamn.Name
ActiveSheet.Cells(lnNamn, 3).Value = "'" & nNamn.RefersTo
ActiveSheet.Cells(lnNamn, 3).InsertIndent 1
On Error Resume Next
Set rnOmrade = nNamn.RefersToRange
If rnOmrade.Cells.Count > 1 Then
ActiveSheet.Cells(lnNamn, 2).Value = "Nothing"
Else
With ActiveSheet.Cells(lnNamn, 2)
.Value = nNamn.Value
.NumberFormat = rnOmrade.NumberFormat
End With
End If
ActiveSheet.Cells(lnNamn, 4) = nNamn.RefersToRange.Address(False, False)
ActiveSheet.Cells(lnNamn, 6).FormulaR1C1 = "=IFERROR(MID(RC[-2],2,15)/1,IFERROR(MID(rc[-2],3,15)/1,""column""))"
ActiveSheet.Cells(lnNamn, 7).FormulaR1C1 = "=IFERROR(MID(RC[-2],2,15)/1,IFERROR(MID(rc[-2],3,15)/1,""""))"
' ActiveSheet.Cells(lnNamn, 8).FormulaR1C1 = "=IFERROR(MID(RC[-2],2,15)/1,IFERROR(MID(rc[-2],3,15)/1,""column""))"
On Error GoTo 0
lnNamn = lnNamn + 1
Fortsatt:
Next nNamn
Set Y = ActiveSheet.Range("D2:D" & ActiveSheet.Range("D65536").End(xlUp).Row)
Y.TextToColumns Destination:=ActiveSheet.Range("D2"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=":", FieldInfo:=Array(Array(1, 1), Array(2, 1))
Columns("A:C").EntireColumn.AutoFit
Columns("B").HorizontalAlignment = xlCenter
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
'instruction eventuelle pour deleter un named range:
'nNamn.delete
End Sub 'Create_Named_Ranges_List