Excel精英培训网

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

一个单元格内某个符合条件的字符标色

[复制链接]
发表于 2019-11-15 11:34 | 显示全部楼层 |阅读模式
求教,如下图标所示颜色如何用VBA代码进行标记,谢谢
Snap1.jpg

标记颜色.rar

6.93 KB, 下载次数: 4

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2019-11-15 12:16 | 显示全部楼层
我好像总看见有人在问这问题,也不知道是不是都是你在问:

Application.ScreenUpdating = False

Dim arr
arr = Range("e2:e" & [e10000].End(3).Row)
Columns("b:b").Select
Selection.Font.ColorIndex = xlAutomatic
Selection.Font.Bold = False

For i = 2 To [b100000].End(3).Row
    For j = 1 To UBound(arr)
        If InStr(Cells(i, 2), arr(j, 1)) > 0 Then
           s1 = InStr(Cells(i, 2), arr(j, 1))
           s2 = Len(arr(j, 1))
           Cells(i, 2).Select
           With ActiveCell.Characters(Start:=s1, Length:=s2).Font
             .FontStyle = "加粗"
             .Color = -16776961
             .ThemeFont = xlThemeFontMinor
           End With
        End If
    Next j
Next i

Cells(1, 1).Select
Application.ScreenUpdating = True

评分

参与人数 1学分 +2 收起 理由
liquanchun + 2 谢谢

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2019-11-15 15:32 | 显示全部楼层
hfwufanhf2006 发表于 2019-11-15 12:16
我好像总看见有人在问这问题,也不知道是不是都是你在问:

Application.ScreenUpdating = False

我是第一次提问,谢谢您
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-20 06:21 , Processed in 0.323408 second(s), 14 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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