Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 2415|回复: 2

[已解决]求老师们帮忙

[复制链接]
发表于 2016-4-20 07:08 | 显示全部楼层 |阅读模式
不知能否实现
最佳答案
2016-4-20 16:10
Sub test()
    Dim within_text As Range
    Dim find_text As String, str As String, ch As String
    Dim strLen As Integer, i As Integer, j As Integer, s As Integer

    Application.ScreenUpdating = False
    Set within_text = [f1]
    find_text = "T"
    str = within_text.Text
    strLen = Len(str)
    Call fillFontColor(1, strLen, 0, within_text)
    j = 1


    For i = 1 To strLen
        ch = Mid(str, i, 1)
        If ch = "," Or ch = ";" Then j = i + 1
        If ch = find_text Then
            Call fillFontColor(j, i - j + 1, -16776961, within_text)
            s = s + 1
        End If
    Next i


    within_text.Offset(0, 1) = s
End Sub


Sub fillFontColor(startIndex As Integer, charCount As Integer, colorValue As Long, within_text As Range)

    within_text.Characters(Start:=startIndex, Length:=charCount).Font.Color = colorValue

End Sub

5.rar (10.8 KB, 下载次数: 5)

查找.zip

7.57 KB, 下载次数: 9

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2016-4-20 11:46 | 显示全部楼层
QQ截图20160420113730.jpg

有空发一个截图,多少能增加一些解答的机会
回复

使用道具 举报

发表于 2016-4-20 16:10 | 显示全部楼层    本楼为最佳答案   
Sub test()
    Dim within_text As Range
    Dim find_text As String, str As String, ch As String
    Dim strLen As Integer, i As Integer, j As Integer, s As Integer

    Application.ScreenUpdating = False
    Set within_text = [f1]
    find_text = "T"
    str = within_text.Text
    strLen = Len(str)
    Call fillFontColor(1, strLen, 0, within_text)
    j = 1


    For i = 1 To strLen
        ch = Mid(str, i, 1)
        If ch = "," Or ch = ";" Then j = i + 1
        If ch = find_text Then
            Call fillFontColor(j, i - j + 1, -16776961, within_text)
            s = s + 1
        End If
    Next i


    within_text.Offset(0, 1) = s
End Sub


Sub fillFontColor(startIndex As Integer, charCount As Integer, colorValue As Long, within_text As Range)

    within_text.Characters(Start:=startIndex, Length:=charCount).Font.Color = colorValue

End Sub

5.rar (10.8 KB, 下载次数: 5)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-17 07:49 , Processed in 0.322313 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表