Excel精英培训网

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

[已解决]为什么A1\C1\H1没有36号显示?

[复制链接]
发表于 2016-3-11 10:58 | 显示全部楼层 |阅读模式
本帖最后由 lingyuncelia1 于 2016-3-13 15:48 编辑

捕获.JPG
Sub 同行隐含三链数法()
a = 5
b = 6
c = 7
For j = 1 To 9
s = CStr(Cells(1, j))
    If s Like "*" & a & "*" & b & "*" Or s Like "*" & a & "*" & c & "*" _
    Or s Like "*" & b & "*" & c & "*" Or s Like "*" & a & "*" & b & "*" & c & "*" Then
    n = n + 1
    x = x & "," & Cells(1, j).Address
    End If
Next
If n = 3 Then
  For j = 1 To 9
    s = CStr(Cells(1, j))
        If Not s Like "*" & a & "*" & b & "*" And Not s Like "*" & a & "*" & c & "*" _
        And Not s Like "*" & b & "*" & c & "*" And Not s Like "*" & a & "*" & b & "*" & c & "*" Then
        y = y & "," & Cells(1, j).Address
        yy = Mid(y, 2)
        End If
  Next
  For j = 1 To 9
            If Not Range(yy).Text Like "*" & a & "*" _                      ‘Range(yy) 是指B1\D1\E1\F1\G1\I1
            And Not Range(yy).Text Like "*" & b & "*" _
            And Not Range(yy).Text Like "*" & c & "*" Then
            Range(Mid(x, 2)).Font.Size = 36                                       ’Range(Mid(x, 2))是指A1\C1\H1
            End If
  Next
End If
n = 0: x = "": y = ""
End Sub


最佳答案
2016-3-11 15:51
是不是想表达这个意思?
  1. Sub 同行隐含三链数法()
  2. a = 5
  3. b = 6
  4. c = 7
  5. For j = 1 To 9
  6.     s = CStr(Cells(1, j))
  7.     If s Like "*" & a & "*" & b & "*" Or s Like "*" & a & "*" & c & "*" _
  8.     Or s Like "*" & b & "*" & c & "*" Or s Like "*" & a & "*" & b & "*" & c & "*" Then
  9.     n = n + 1
  10.     x = x & "," & Cells(1, j).Address
  11.     Else
  12.         y = y & Cells(1, j)
  13.     End If
  14. Next

  15. If n = 3 Then
  16.     If Not y Like "*" & a & "*" And Not y Like "*" & b & "*" _
  17.     And Not y Like "*" & c & "*" Then
  18.         Range(Mid(x, 2)).Font.Size = 36
  19.     End If
  20. End If
  21. n = 0: x = "": y = ""
  22. End Sub

复制代码

歌剧魅影.zip

13.15 KB, 下载次数: 8

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2016-3-11 15:51 | 显示全部楼层    本楼为最佳答案   
是不是想表达这个意思?
  1. Sub 同行隐含三链数法()
  2. a = 5
  3. b = 6
  4. c = 7
  5. For j = 1 To 9
  6.     s = CStr(Cells(1, j))
  7.     If s Like "*" & a & "*" & b & "*" Or s Like "*" & a & "*" & c & "*" _
  8.     Or s Like "*" & b & "*" & c & "*" Or s Like "*" & a & "*" & b & "*" & c & "*" Then
  9.     n = n + 1
  10.     x = x & "," & Cells(1, j).Address
  11.     Else
  12.         y = y & Cells(1, j)
  13.     End If
  14. Next

  15. If n = 3 Then
  16.     If Not y Like "*" & a & "*" And Not y Like "*" & b & "*" _
  17.     And Not y Like "*" & c & "*" Then
  18.         Range(Mid(x, 2)).Font.Size = 36
  19.     End If
  20. End If
  21. n = 0: x = "": y = ""
  22. End Sub

复制代码

评分

参与人数 2 +6 收起 理由
lingyuncelia1 + 3 很给力
白云无尽9987 + 3 赞一个

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2016-3-13 15:47 | 显示全部楼层
grf1973 发表于 2016-3-11 15:51
是不是想表达这个意思?

是的,就是这个意思,上次你也给过我类似的答案的。可惜当时理解上还是有偏差,因此扩展成9行的时候出错了。现在应该是明白了,已经能在你答案的基础上扩展9行了。谢谢大侠!
回复

使用道具 举报

 楼主| 发表于 2016-3-13 17:01 | 显示全部楼层
您这个代码是可行的,但我还是不明白,我自己写的那个代码为什么不行。我明明已经用断点于黄色背景的代码调试过了,可惜无法发现错误。大侠你明白各种原因吗?
回复

使用道具 举报

发表于 2016-3-14 09:24 | 显示全部楼层
针对你的代码:
For j = 1 To 9
            If Not Range(yy).Text Like "*" & a & "*" _                      ‘Range(yy) 是指B1\D1\E1\F1\G1\I1
            And Not Range(yy).Text Like "*" & b & "*" _
            And Not Range(yy).Text Like "*" & c & "*" Then
            Range(Mid(x, 2)).Font.Size = 36                                       ’Range(Mid(x, 2))是指A1\C1\H1
            End If
  Next

1、首先,For循环没有任何意义
2、你调试一下yy的值,应该是6个地址的组成的字符串,就没有Range("B1,C1...").Text这种用法。
3、我猜你的意思是:如果把yy所对应的所有单元格的值都不含a,b,c就把x对应单元格字体变大。
     这可以在前面找x的时候就把yy所有的内容串起来。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-26 06:42 , Processed in 0.382466 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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