excel - 关注特定单元格时在特定单元格中添加文本
问题描述
当我在单元格 E18 上有我的“焦点”(所以当我单击此单元格时)时,如何在单元格 C18 中添加文本?在此处搜索其他问题时,我尝试了一些代码组合,但没有任何反应。
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets(1)
Dim myCell As Range: Set myCell = ws.Range("E18")
Dim iSect As Range
Set iSect = Application.Intersect(Target, myCell)
'If the selection is not your cell, exit sub
If iSect Is Nothing Then Exit Sub
Range("$C$18").Value = "HERE IS THE TEXT I WANT"
End Sub
谢谢你的帮助
解决方案
这适用于我的工作表。让我知道!
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim trigger As Range
Set trigger = Range("E18")
If Intersect(ActiveCell, trigger) Is Nothing Then Exit Sub
If Not (Intersect(ActiveCell, trigger) Is Nothing) Then
Range("C18").Value = "Here is the text I want"
End If
End Sub
推荐阅读
- html - -webkit-background-clip 在 Safari 中不起作用
- sql - 学生,课程和出勤之间的SQL关系
- python - 如何查看多个数据框的头列?
- r - 用不同列中先前值和当前值的总和替换 NA 的值
- node.js - 错误:找不到模块“./build/Release/DTraceProviderBindings”
- r - FitDist 错误:'数据必须是长度大于 1 的数字向量'
- javascript - 画布图像旋转性能
- node.js - 忽略已完成函数的异常
- machine-learning - 如何确定 CartPole 环境何时解决?
- database - Codeigniter foreach 选择菜单“已选择”选项