如何将预定义文本作为纯文本输入到活动单元格中?

发布于 2025-01-13 13:54:22 字数 343 浏览 1 评论 0原文

我希望按 F1(Windows 操作系统)打印,即活动 Excel 单元格中的“XZ”(作为纯文本/无格式文本),但这样我就可以输入“123”此后立即执行,因此导致单元格值为 XZ123。

.xls 由其他用户共享,其中有四个用户在任何给定时间都在文档中添加数据。我们将其保存到 SharePoint 文件夹,但团队中没有人通过 Web 版本的 Excel 访问该文档。相反,我们只需双击文档,此时 Excel 将从本地硬盘启动,但当文档加载时,我们可以根据单元格周围的突出显示及其缩写来查看其他用户的活动单元格。

我希望这个两个字母的自动化可以从我的计算机触发,而不是嵌入到文档文件本身中。

I wish to press F1 (Windows OS) to print, i.e., "XZ" in the active Excel cell (as plain/unformatted text), but in such a way that I can then enter "123" immediately thereafter, hence resulting in a cell value of XZ123.

This .xls is shared by other users, four of whom are in the document adding data at any given time. We save this to a SharePoint folder, but nobody on the team ever accesses the document via the web version of Excel. We instead just double-click the document, at which point Excel boots up from our local hard drive, but when the document loads, we can see other users' active cell(s) based on highlights around the cells with their initials.

My hope is that this two-letter automation can be triggered from my computer, and not embedded in the document file itself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你是年少的欢喜 2025-01-20 13:54:22

不幸的是,vba 进入编辑模式的唯一方法是使用 SendKeys

您需要使用OnKey 将功能映射到 F1

Const StringToEnter As String = "XZ"

Sub EnterValue()
    Application.SendKeys "{F2}" & StringToEnter
End Sub

' Run this once to map F1 key.  Maybe call from the `Workbook_Open` event
Sub SetupMappingToF1()
    Application.OnKey "{F1}", "EnterValue"
End Sub

Unfortunately the only way for vba to enter edit mode is to use SendKeys

You'll need to use OnKey to map the function to F1

Const StringToEnter As String = "XZ"

Sub EnterValue()
    Application.SendKeys "{F2}" & StringToEnter
End Sub

' Run this once to map F1 key.  Maybe call from the `Workbook_Open` event
Sub SetupMappingToF1()
    Application.OnKey "{F1}", "EnterValue"
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文