在Excel 2010中了解单元格的命名范围的快捷方式 [英] Shortcut to know Named Range of a Cell in Excel 2010

查看:138
本文介绍了在Excel 2010中了解单元格的命名范围的快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



如果有任何捷径可以通过

放置知道excel单元格的命名范围,请告诉我。将光标放在单元格上。

Hi guys

Please let me know if there is any shortcut to know the named range of a excel cell by just
placing the cursor over the cell.

推荐答案

要做的步骤:

1)转到代码窗格:ALT + F11

2)添加新模块

3)复制并粘贴下面的代码:

Steps to do:
1) Go to the code pane: ALT+F11
2) Add new module
3) Copy and paste below code:
Option Explicit

Sub test()
MsgBox GetNamedRange(Workbooks("YourWorkbookName.xls").Worksheets("YourWorksheetName").Range("A2"))
MsgBox GetNamedRange(ActiveCell)
End Sub

'returns the name of NamedRange
Function GetNamedRange(rng As Range) As String
Dim r As Range, n As Name
Dim wsh As Worksheet, wbk As Workbook
Dim sRetVal As String

On Error Resume Next

Set wsh = rng.Parent
Set wbk = wsh.Parent

'go through the collection of names, including the all worksheet-specific names
For Each n In wbk.Names
    r = n.RefersTo
    If r.Address = rng.CurrentRegion.Address Then
        sRetVal = n.NameLocal
        Exit For
    End If
Next

GetNamedRange = sRetVal

End Function



4)测试


4) Test it


这篇关于在Excel 2010中了解单元格的命名范围的快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆