level 1
marm0t
楼主
代码如下:
Sub 显示成交()
Dim t As Date
Dim txtBox As Shape
Dim txtbox1 As Shape
Do
t = Time ' 获取时间
' 添加文本框
Set txtBox = ActiveSheet.Shapes.AddTextbox( _
msoTextOrientationHorizontal, _
Left:=1, Top:=1, Width:=370, Height:=170)
' 设置文本框的字体大小
txtBox.TextFrame2.TextRange.Font.Size = 48
' 设置文本框背景颜色
txtBox.Fill.ForeColor.RGB = RGB(255, 255, 160)
txtBox.Fill.Visible = msoTrue
' 设置文本框字体加粗
txtBox.TextFrame2.TextRange.Font.Bold = msoTrue
For i = 1 To Range("A1").End(xlDown).Row
If Range("a" & i).Text = Format(t, "hh:mm:ss") Then txtBox.TextFrame2.TextRange.Text = Range("b" & i)
Next
DoEvents
Loop
End Sub
测试程序的时候,总是跳过a列中某些时间,不显示对应b列内容,这是什么问题?
传不了excel文件,我截图。

测试结果我传个视频,截取了一小段。
352.353.断.355.356.断.367.368.369.断.372.373.断.375
2024年08月04日 09点08分
1
Sub 显示成交()
Dim t As Date
Dim txtBox As Shape
Dim txtbox1 As Shape
Do
t = Time ' 获取时间
' 添加文本框
Set txtBox = ActiveSheet.Shapes.AddTextbox( _
msoTextOrientationHorizontal, _
Left:=1, Top:=1, Width:=370, Height:=170)
' 设置文本框的字体大小
txtBox.TextFrame2.TextRange.Font.Size = 48
' 设置文本框背景颜色
txtBox.Fill.ForeColor.RGB = RGB(255, 255, 160)
txtBox.Fill.Visible = msoTrue
' 设置文本框字体加粗
txtBox.TextFrame2.TextRange.Font.Bold = msoTrue
For i = 1 To Range("A1").End(xlDown).Row
If Range("a" & i).Text = Format(t, "hh:mm:ss") Then txtBox.TextFrame2.TextRange.Text = Range("b" & i)
Next
DoEvents
Loop
End Sub
测试程序的时候,总是跳过a列中某些时间,不显示对应b列内容,这是什么问题?
传不了excel文件,我截图。

测试结果我传个视频,截取了一小段。352.353.断.355.356.断.367.368.369.断.372.373.断.375
