ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 2296|回复: 7

[求助]高手们请帮帮忙

[复制链接]

TA的精华主题

TA的得分主题

发表于 2008-5-17 23:11 | 显示全部楼层 |阅读模式

Problem fixed, Thanks WokIbmV7.rar (8.75 KB, 下载次数: 31)

Different Conditional format's formula were generated by same marco.

 


 

[em06]
[此贴子已经被作者于2008-5-18 14:58:34编辑过]

TA的精华主题

TA的得分主题

发表于 2008-5-17 23:49 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
干嘛写英文。

TA的精华主题

TA的得分主题

 楼主| 发表于 2008-5-18 00:10 | 显示全部楼层

Sorry, I didnot know chinese typing, very sorry.

TA的精华主题

TA的得分主题

发表于 2008-5-18 01:37 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助

Help what?

是否这样:

Sub Fsconformat()

Dim endrow As Integer
endrow = ActiveSheet.[a65536].End(xlUp).Row
Set arr = [d2].Resize(endrow - 1, 66)
Cells.FormatConditions.Delete
    arr.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=AND($A2<=D$1,$B2>=D$1,$C2=""正常"")"
    arr.FormatConditions(1).Interior.ColorIndex = 3
    arr.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=AND($A2<=D$1,$B2>=D$1,$C2=""延迟"")"
    arr.FormatConditions(2).Interior.ColorIndex = 41
    arr.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=AND($A2<=D$1,$B2>=D$1,$C2=""提前"")"
    arr.FormatConditions(3).Interior.ColorIndex = 6
End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2008-5-18 09:25 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册

回复:(KCFONG)[求助]高手们请帮帮忙

9altYrIW.rar (110.87 KB, 下载次数: 23)

You macro seem not work also, the formula generated was

=AND($A65527<=IV$1,$B65527>=IV$1,$C65527="正常")

my expected formula was =AND($A$2<=D$1,$B$2>=D$1,$C$2="正常")

Please refer to attached file, sheets(sheet2). There were picture shown my request

TA的精华主题

TA的得分主题

 楼主| 发表于 2008-5-18 13:59 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2008-5-18 15:57 | 显示全部楼层
Sub xxFsconformat()
Dim endrow As Integer, r As Integer
Dim ca As String
Dim conf As String
endrow = ActiveSheet.[a65536].End(xlUp).Row
Cells.FormatConditions.Delete
conf = "=AND(RC1<=r1c,rc2>=r1c,rc3"
For r = 2 To endrow
  Add = ("$d$" & r & ":$bq$" & r)
   Range(Add).FormatConditions.Add Type:=xlExpression, Formula1:=conf & "=""正常"")"
    Range(Add).FormatConditions(1).Interior.ColorIndex = 3
   
    Range(Add).FormatConditions.Add Type:=xlExpression, Formula1:=conf & "=""延迟"")"
    Range(Add).FormatConditions(2).Interior.ColorIndex = 41
   
    Range(Add).FormatConditions.Add Type:=xlExpression, Formula1:=conf & "=""提前"")"
    Range(Add).FormatConditions(3).Interior.ColorIndex = 6
 Next
 
  
End Sub

TA的精华主题

TA的得分主题

发表于 2008-5-18 22:14 | 显示全部楼层

Why, different conditional format’s formula were generated by same marco?

Reason:

The address of cell in conditional format’s formula refer ONLY to the activate cell(s) or Selection. If we select the different cell before marco run, the formula shows different cell’s address after marco run.

Solving method:

add the code “Range(Add).select” in LZ’macro:

conf = "=and($A$" & r & "<=" & ca & ",$B$" & r & ">=" & ca & ",$C$" & r

Range(Add).Select

Range(Add).FormatConditions.Add Type:=xlExpression, Formula1:=conf & "=""Normal"")"

Under same case, add “arr.select” in my macro:

Cells.FormatConditions.Delete

arr.Select

arr.FormatConditions.Add Type:=xlExpression, Formula1:= _

    "=AND($A2<=D$1,$B2>=D$1,$C2=""Normal"")"

 

 

Shizx98’s macro was correct, by using R1C1 expression

[此贴子已经被作者于2008-5-18 22:19:25编辑过]
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-3-29 09:04 , Processed in 0.055015 second(s), 12 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

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