使用displayformat方法设置数据范围的格式

使用displayformat方法设置数据范围的格式

ID:12749008

大小:27.45 KB

页数:4页

时间:2018-07-18

使用displayformat方法设置数据范围的格式_第1页
使用displayformat方法设置数据范围的格式_第2页
使用displayformat方法设置数据范围的格式_第3页
使用displayformat方法设置数据范围的格式_第4页
资源描述:

《使用displayformat方法设置数据范围的格式》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、e800,国内最具活力的IT门户网站。http://www.e800.com.cn【e800编译】此示例演示在MicrosoftExcel2010中如何利用DisplayFormat类对一定范围的数据设置条件格式。此代码段是Office2010的101项VBA代码示例中的一部分。与其它示例一样,这些将可以直接写入您的代码中。每块示例代码包含约5至50行的代码,分别演示了一个独特的功能或功能集,在VBA或VB以及C#中(在VisualStudio2010中创建)。每个示例之中都会包含代码以及相应注

2、释,这样您就可以直接运行获取预期的结果,或者是根据代码注释提示来调整环境,运行示例代码。MicrosoftOffice2010提供了你所需要的工具来创建功能强大的应用程序。MicrosoftVisualBasicApplication(VBA)代码示例可以帮助你创建自己的应用程序,以执行特定功能或者以此为出发点实现更为复杂的功能。实例代码在Excel2010中新建工作簿,将代码复制到Sheet1类模块,然后按F5全速运行程序。检查在Excel中的单元格的格式,然后检查代码运行结果。'Excel2

3、010SubTestDisplayFormat()'Fromthedocumentation:'Actionssuchaschangingtheconditionalformattingor'tablestyleofarangecancausewhatisdisplayedin'thecurrentuserinterfacetobeinconsistentwiththe'valuesinthecorrespondingpropertiesoftheRangeobject.'Usetheprope

4、rtiesoftheDisplayFormatobjecttoreturn'thevaluesastheyaredisplayedinthecurrentuserinterface.'InExcel2010,inanewworkbook,copyallthiscodeinto'theSheet1classmodule.Placethecursorinthisprocedure,'andthenpressF5toruntheprocedurefullspeed.Examine'theformatt

5、ingofthecellsinExcel,andthenexamine'theresultsofrunningtheprocedureintheImmediatewindow.'ThisexampleplacessomesimpledataintoSheet1,ande800,国内最具活力的IT门户网站。http://www.e800.com.cn'thenappliesconditionalformatting.'Then,itcomparesthevaluesofvarious'format

6、tingpropertiesoftherangetothe'formattingpropertiesoftheRange.DisplayFormatobject:Range("A1").Value=-20Range("A2").Value=10DimrngAsRangeSetrng=Range("A1:A2")'Setuptheconditionalformatting:rng.FormatConditions.AddType:=xlCellValue,Operator:=xlLess,Form

7、ula1:="=0"Withrng.FormatConditions(1)With.Font.Bold=True.Italic=True.Color=vbRedEndWithWith.Borders.LineStyle=xlContinuous.Weight=xlThinEndWithWith.Interior.PatternColorIndex=xlAutomatic.Color=vbYellowe800,国内最具活力的IT门户网站。http://www.e800.com.cnEndWithE

8、ndWith'Nowcompareformattinginformationfortherange,and'whatit'sactuallydisplaying(usingtheDisplayFormatproperty).'Clearly,withouttheDisplayFormatproperty,youhavenoway'tofindouttheformattingthatappearstotheuser.The'DisplayFormatpropertyisaninstanceofth

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。