gpt4 book ai didi

excel - 如何在多行/单元格上书写

转载 作者:行者123 更新时间:2023-12-04 22:29:19 25 4
gpt4 key购买 nike

我正在尝试编写一个循环宏以从我的事件单元格中的多个连续行(例如 1000)上写入文本。我在下面粘贴了我已经尝试过的内容......我想我可能已经接近了,但我显然错过了一些重要的细节。有人可以帮忙吗?

Sub firstloop()
Dim Total As Long
Dim Count As Long
Total = 0
For Count = 1 To 1000
Count = Total + Count
ActiveCell = "Test"
ActiveCell.Offset(1, 0) = ActiveCell
Next Count
End Sub

最佳答案

摆脱两个ActiveCell并使用:

Sub firstloop()

Dim rng as range
Set rng = selection

Dim Count As Long
For Count = 1 To 1000
rng.offset(count - 1,0).Value = "Test"
Next Count
End Sub

关于excel - 如何在多行/单元格上书写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54575982/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com