|
![](https://clubstatic.excelhome.net/image/common/ico_lz.png)
楼主 |
发表于 2024-7-26 22:00
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 marmot777 于 2024-7-27 00:56 编辑
导入系统时间,当系统时间和A列时间数据相同的时候,在文本框显示B列内容。
Sub 显示成交()
Dim t As Date
Dim txtBox 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) = t Then txtBox.TextFrame2.TextRange.Text = Range("b" & i)
g = txtBox.TextFrame2.TextRange.Text
For c = 1 To Len(g)
If Mid(g, c, 1) = "成" Then txtBox.TextFrame.Characters(c, 1).Font.Color = RGB(155, 60, 18)
If Mid(g, c, 1) = "交" Then txtBox.TextFrame.Characters(c, 1).Font.Color = RGB(155, 60, 18)
If Mid(g, c, 1) = "(" Then txtBox.TextFrame.Characters(c, 1).Font.Color = RGB(155, 60, 18)
If Mid(g, c, 1) = ")" Then txtBox.TextFrame.Characters(c, 1).Font.Color = RGB(155, 60, 18)
If Mid(g, c, 1) = "挂" Then txtBox.TextFrame.Characters(c, 1).Font.Color = vbBlue
If Mid(g, c, 1) = "撤" Then txtBox.TextFrame.Characters(c, 1).Font.Color = RGB(128, 0, 255)
Next
Next
DoEvents
Loop
End Sub
调试的时候总是有时间跳过去,不显示B列内容,哪地方写的不对?
|
|