作为记录,我对编码的经验非常有限。我们使用Excel记录一天中所有的实时事件。报表大约有100到150行长,每行有多行。每行使用12个合并单元格,并对文本进行包装。
所需的操作:在光标后面插入特定的文本,在已经包含文本的单元格中插入(使用VB的MS 2013 Excel )。
下面的代码可以工作,除非它将文本放在单元格的顶部而不是光标处。我们不能使用文本框,而且录音也不起作用。什么代码能做到这一点?谢谢!
Sub SuziQueue ()
With ActiveCell
.Value = "<Suzi Queue... >" & .Value
End With
End Sub 发布于 2015-09-01 06:03:56
也许这个例子会有帮助
。
Option Explicit
Sub insertText()
Dim indx As Long, lastPart As String
With ActiveCell
MsgBox .Value2 'shows "Test String"
indx = InStr(.Value2, "S")
lastPart = Right(.Value2, indx + 1)
.Characters(indx).Insert "New" & lastPart 'inserts "New" between "Test" & "String"
MsgBox .Value2 'shows "Test New String"
End With
End Sub。
可能有一些方法可以使用APIs确定单元格中的光标位置。
此Microsoft链接展示了如何在屏幕上获得光标位置。
https://stackoverflow.com/questions/32320797
复制相似问题