ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

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

[分享]增强型状态栏

[复制链接]

TA的精华主题

TA的得分主题

发表于 2007-8-20 10:34 | 显示全部楼层 |阅读模式

效果: rb8TGqT2.rar (12.14 KB, 下载次数: 134)


代码:

QUOTE:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("AutoCalculate").Reset
End Sub
Private Sub Workbook_Open()
    With Application.CommandBars("AutoCalculate").Controls.Add(Type:=msoControlButton, before:=1, Temporary:=True)
    .Caption = "全部计算(&A)"
    .OnAction = "计算"
     .FaceId = 483
     Application.CommandBars("AutoCalculate").Controls(2).BeginGroup = True
     Application.CommandBars("AutoCalculate").Controls(3).BeginGroup = False
     End With
End Sub
Sub 计算()
    Dim msg As String, cell As Range, i As Integer, temp
   Dim str As String, ChineseChar As Long, Alphabetic As Long, Number As Long
  Dim rng As Range, j As Long
    If TypeName(Selection) <> "Range" Then MsgBox "请选择单元格!", 64, "【友情提示】": Exit Sub
    For Each cell In Selection
    If VBA.IsNumeric(cell.Value) And cell <> "" Then i = i + 1
    Next
    If i = 0 Then
    msg = "平均值:0"
    Else
    msg = "平均值:" & WorksheetFunction.Average(Selection)
    End If
    msg = msg & Chr(10) & "计  数:" & WorksheetFunction.Count(Selection)
    msg = msg & Chr(10) & "计数值:" & WorksheetFunction.CountA(Selection)
    msg = msg & Chr(10) & "最大值:" & WorksheetFunction.Max(Selection)
    msg = msg & Chr(10) & "最小值:" & WorksheetFunction.Min(Selection)
    msg = msg & Chr(10) & "和  计:" & WorksheetFunction.Sum(Selection)
    msg = msg & Chr(10) & "单元格:" & Selection.Count
    MsgBox "您的选区:" & Chr(10) & msg, 64, "【友情提示】"
  For Each rng In Selection
    j = j + Len(rng.Value)
    For i = 1 To Len(rng)
      str = Mid(rng.Value, i, 1)
      If str Like "[一-龥]" = True Then
        ChineseChar = ChineseChar + 1
      ElseIf str Like "[a-zA-Z]" = True Then
        Alphabetic = Alphabetic + 1
      ElseIf str Like "[0-9]" = True Then
        Number = Number + 1
      End If
    Next
  Next
  MsgBox "所选单元格区域中共有字数" & j & "个。" & Chr(10) & "汉字:" & ChineseChar & "个" & _
     Chr(10) & "字母:" & Alphabetic & "个" & Chr(10) & "数字:" & Number & "个" & Chr(10) _
     & "特殊字符及空格:" & j - Alphabetic - Number - ChineseChar & "个。", vbInformation, "字符统计"

End Sub



[分享]增强型状态栏

[分享]增强型状态栏

TA的精华主题

TA的得分主题

 楼主| 发表于 2007-8-20 11:05 | 显示全部楼层

為了方便繁體版朋友,以後我的程序盡量做兩個版本)

再給一個繁體版的加載宏


karAxL60.rar (11 KB, 下载次数: 19)

QUOTE:


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("AutoCalculate").Reset
End Sub

Private Sub Workbook_Open()
    With Application.CommandBars("AutoCalculate").Controls.Add(Type:=msoControlButton, before:=1, Temporary:=True)
    .Caption = "全部計算(&A)"
    .OnAction = "計算"
     .FaceId = 483
     Application.CommandBars("AutoCalculate").Controls(2).BeginGroup = True
     Application.CommandBars("AutoCalculate").Controls(3).BeginGroup = False
     End With
End Sub

Sub 計算()
    Dim msg As String, cell As Range, i As Integer, temp
   Dim str As String, ChineseChar As Long, Alphabetic As Long, Number As Long
  Dim rng As Range, j As Long
    If TypeName(Selection) <> "Range" Then MsgBox "請選擇單元格", 64, "友情提示": Exit Sub
    For Each cell In Selection
    If VBA.IsNumeric(cell.Value) And cell <> "" Then i = i + 1
    Next
    If i = 0 Then
    msg = "平均值:" & vbTab & "0"
    Else
    msg = "平均值:" & vbTab & WorksheetFunction.Average(Selection)
    End If
    msg = msg & Chr(10) & "項目個數:" & vbTab & WorksheetFunction.Count(Selection)
    msg = msg & Chr(10) & "數字個數:" & vbTab & WorksheetFunction.CountA(Selection)
    msg = msg & Chr(10) & "最大值:" & vbTab & WorksheetFunction.Max(Selection)
    msg = msg & Chr(10) & "最小值:" & vbTab & WorksheetFunction.Min(Selection)
    msg = msg & Chr(10) & "總計數:" & vbTab & WorksheetFunction.Sum(Selection)
    msg = msg & Chr(10) & "單元格:" & vbTab & Selection.Count
    MsgBox "您的選區:" & Chr(10) & msg, 64, "全部計算"
  For Each rng In Selection
    j = j + Len(rng.Value)
    For i = 1 To Len(rng)
      str = Mid(rng.Value, i, 1)
      If str Like "[一-顩]" = True Then
        ChineseChar = ChineseChar + 1
      ElseIf str Like "[a-zA-Z]" = True Then
        Alphabetic = Alphabetic + 1
      ElseIf str Like "[0-9]" = True Then
        Number = Number + 1
      End If
    Next
  Next
  MsgBox "您的選區共有" & j & "個字符。" & Chr(10) & "其中漢字" & ChineseChar & "個" & _
     Chr(10) & "字母" & Alphabetic & "個" & Chr(10) & "數字" & Number & "個" & Chr(10) _
     & "標點及特殊字符" & j - Alphabetic - Number - ChineseChar & "個", vbInformation, "統計"

End Sub


[此贴子已经被作者于2007-8-20 11:42:37编辑过]

TA的精华主题

TA的得分主题

发表于 2007-8-20 14:00 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
非常感謝 andysky 版主提供分享 !!!
[em23][em23][em23][em23][em23][em23]
[em24][em24][em24][em24][em24][em24]
[em27][em27][em27][em27][em27][em27]

TA的精华主题

TA的得分主题

发表于 2007-8-27 17:18 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2007-8-27 20:30 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2007-8-28 00:00 | 显示全部楼层
感谢版主分享哦,又有新的工具咯

TA的精华主题

TA的得分主题

发表于 2007-10-1 19:49 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2007-10-1 20:02 | 显示全部楼层

学习了

原来这个叫CommandBars("AutoCalculate")

TA的精华主题

TA的得分主题

发表于 2011-7-16 18:19 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
代码怎么运行

TA的精华主题

TA的得分主题

发表于 2012-10-26 11:33 | 显示全部楼层
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

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

GMT+8, 2024-11-24 07:21 , Processed in 0.052824 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

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

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

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