Excel精英培训网

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

[已解决]帮忙修改提取后显示字体带颜色

[复制链接]
发表于 2016-7-21 23:00 | 显示全部楼层 |阅读模式
本帖最后由 hanjia 于 2016-7-24 12:46 编辑

字体颜色,1跟2显示为黑色,不用对比
3以上对比,大于背景色单元格数据的显示红色
小于背景色单格数据显示黑色,3以上相同的显示蓝色
0大于9,比如B20带背景色单元格的数据是4
提取到B5是4,B2是0的话 那就B2的0显示红色

要是可以的话就再帮忙写条从W2提取   先谢了

工作表2.zip (11.77 KB, 下载次数: 3)
 楼主| 发表于 2016-7-23 14:41 | 显示全部楼层
回复

使用道具 举报

发表于 2016-7-24 11:20 | 显示全部楼层    本楼为最佳答案   
  1. Sub xx()
  2.     Dim x%, z%, y%
  3.     With Sheet1
  4.         x = .Cells(17, .Columns.Count).End(1).Column
  5.         .[C2:C10].ClearContents
  6.         For i = 17 To 24
  7.             If .Cells(i, x).Interior.Color = 49407 Then
  8.                 z = .Cells(i, x)
  9.                 y = i - 15
  10.                 Exit For
  11.             End If
  12.         Next
  13.         For i = 1 To 9
  14.             .Cells(i, 2) = .Cells(i + 15, x)
  15.             If .Cells(i, 2) = 0 Or .Cells(i, 2) > z Then
  16.                 .Cells(i, 2).Font.Color = 255
  17.             Else
  18.                 .Cells(i, 2).Font.Color = 0
  19.             End If
  20.             If z = 0 Then .Cells(i, 2).Font.Color = 0
  21.             If .Cells(i, 2) = z Then
  22.                 .Cells(i, 2).Font.Color = 11312130
  23.                 .Cells(i, 2).Offset(0, 1).Font.Color = 255
  24.             End If
  25.             If .Cells(i, 2) = 1 And i <> y Then .Cells(i, 2).Font.Color = 0
  26.             If .Cells(i, 2) = 2 And i <> y Then .Cells(i, 2).Font.Color = 0
  27.         Next
  28.         .Cells(y, 3) = "色位"
  29.         .Cells(y, 3).Offset(0, 1).Font.Color = 255
  30.         .[C10] = z
  31.     End With
  32. End Sub
复制代码

评分

参与人数 1 +3 收起 理由
hanjia + 3 赞一个

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-3-29 07:10 , Processed in 0.518096 second(s), 13 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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