|
本帖最后由 qunzhujunjun 于 2023-2-27 16:20 编辑
单击任意单元格,单元格里面内容,提取到C1,求VBA
注:表格已经有以下VBA代码了,在这个VBA的基础上添加提取内容的代码,谢谢
Private Sub Worksheet_SelectionChange(ByVal Tg As Range)
On Error Resume Next
Application.EnableEvents = False
Dim rg As Range, sp As Shape, dz$
If Intersect(Tg, [C3:C20]) Is Nothing Then GoTo xxx
Me.Shapes(1).Delete
Set rg = Sheet2.Range("a:a").Find(Tg.Value, , , 1)
If Not rg Is Nothing Then dz = rg(1, 2).Address Else GoTo xxx
For Each sp In Sheet2.Shapes
If sp.TopLeftCell.Address = dz Then
sp.CopyPicture
Me.[E2].Select
Me.Paste
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.Height = Me.[E2].MergeArea.Height
Selection.Width = Me.Range("E2").Width
Exit For
End If
Next
Me.[C2].Select
xxx:
Application.EnableEvents = True
End Sub
|
|