这是一个棘手的问题!
我想让一个单词或短语从右到左在单行中的 30 个单元格范围内爬行,在一个循环中连续重复,并且在移动时足够慢以阅读。
任何人都可以帮助提供代码!
我已经设法一次完成一个字符,但我想让整个单词爬行,每个单元格一个字符。
这是迄今为止我面临的最艰难的 vba 挑战!
提前致谢。
这是我的基本版本的代码片段:
For CounterTxt = 1 To textLngt
chaseEnd = chaseEnd + 1
For CounterChase = chaseBeg To chaseEnd - 1 Step -1
Worksheets("Sheet1").Cells(7, CounterChase + 1).Value = "" ' deleats previous chase position while running.
Worksheets("Sheet1").Cells(7, CounterChase).Value = Mid(MyText, CounterTxt, 1)
Sleep 20
Next CounterChase
Next CounterTxt
最佳答案
Sub March()
Dim str As String
str = "Hello World"
Dim rng As Range
Set rng = Worksheets("Sheet1").Range("A1:Z1")
rng.ClearContents
Dim secondstr As String
secondstr = str & Application.Rept(" ", rng.Cells.Count)
Dim vlue As String
vlue = StrConv(secondstr, vbUnicode)
Dim substr() As String
substr = Split(Left(vlue, Len(vlue) - 1), vbNullChar)
Dim i As Long
For i = rng.Cells.Count + rng.Column - 1 To rng.Column Step -1
If i = rng.Column Then
Dim j As Long
For j = 0 To Len(str)
Dim k As Long
For k = 1 To Len(str) + 1
rng.Cells(1, k) = substr(j + k - 1)
Next k
Application.Wait Now() + 1 / (24 * 60 * 60#)
Next j
Else
rng.Cells(1, i).Resize(, Application.Min(Len(secondstr), rng.Cells.Count - i + 1)) = substr
Application.Wait Now() + 1 / (24 * 60 * 60#)
End If
Next i
March
End Sub
关于vba - 使文本在单行的一系列单元格中从右到左爬行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52120419/