Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 在Userform标签中使用活动单元格值_Excel_Vba - Fatal编程技术网

Excel 在Userform标签中使用活动单元格值

Excel 在Userform标签中使用活动单元格值,excel,vba,Excel,Vba,如何在Userform的标签中使用target.value?不管我怎么做,我都会出错。(运行时“438”:对象不支持属性或方法) 我希望userform在更改单元格编号时显示: 我的工作表代码: Private Sub Worksheet_Change(ByVal Target As Range) Dim KeyCells As Range Set KeyCells = Range("D8:D12") If Not Application.Intersect(KeyCell

如何在Userform的标签中使用target.value?不管我怎么做,我都会出错。(运行时“438”:对象不支持属性或方法)

我希望userform在更改单元格编号时显示:

我的工作表代码:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range


    Set KeyCells = Range("D8:D12")

If Not Application.Intersect(KeyCells, Target) Is Nothing Then

        UserForm1.Show

End If
End Sub
我的用户表单代码与我想象中的工作方式相同(但不起作用):


工作表
对象中没有
目标
属性。您可以在
工作表\u Change
方法中设置标签:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range

    Set KeyCells = Range("D8:D12")

    If Not Application.Intersect(KeyCells, Target) Is Nothing Then
        UserForm1.Label1.Caption = Target.Offset(0, -1).Value
        UserForm1.Show

    End If
End Sub

那么,您会遇到什么错误?运行时“438”:对象不支持属性或方法
工作表中没有
目标
属性。
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range

    Set KeyCells = Range("D8:D12")

    If Not Application.Intersect(KeyCells, Target) Is Nothing Then
        UserForm1.Label1.Caption = Target.Offset(0, -1).Value
        UserForm1.Show

    End If
End Sub