Excel 在Userform标签中使用活动单元格值
如何在Userform的标签中使用target.value?不管我怎么做,我都会出错。(运行时“438”:对象不支持属性或方法) 我希望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
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