VBA语法,用于正确格式化的输出

时间:2013-12-02 11:38:14

标签: excel vba excel-vba

我正在使用最初由RBarryYoung提供的以下vba。它很接近,但并不完全存在。

Sub quote()
' get the current selection
Dim rng As Range
Set rng = Selection
If rng Is Nothing Then
    MsgBox "Nothing Selected", vbOKOnly, "Cannot Define Local Name"
    Exit Sub
End If

' get the current worksheet
Dim wks As Worksheet
Set wks = rng.Worksheet
Sht = ActiveSheet.Name
xps = "!"


' get the name to define
Dim sNam As String
sNam = InputBox("Enter the Name to Define for this Sheet:", "Define Local Name")
If sNam = "" Then Exit Sub

' define a name local to this worksheet
wks.Names.Add sNam, Sht & rng.Address

End Sub

问题是本地“引用”定义格式不正确。应该是这个

='VMware Servers'!$K$45

但我得到的最接近的是:

="'VMware Servers'!$K$45"

正因为如此,价值已经关闭,从而打破了一切。

0 个答案:

没有答案