Excel精英培训网

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

[已解决][求助]帮我设置一个右键快捷键

[复制链接]
发表于 2012-1-9 13:56 | 显示全部楼层 |阅读模式
在Excel表格中“跨列居中”只能在单元格格式里面去调整。
请高手帮我做一个右键的快捷键,把这个“跨列居中”调入右键菜单。
以后就直接右键去选择就可以用了。谢谢
最佳答案
2012-1-9 14:00
本帖最后由 sunjing-zxl 于 2012-1-9 14:01 编辑

  1. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  2.     With Application.CommandBars("cell")
  3.         .Reset  
  4.         End With
  5. End Sub
  6. Private Sub Workbook_Open()
  7.     ' 单元格区域右键菜单
  8.     With Application.CommandBars("cell")
  9.         .Reset
  10.         ' 添加控件
  11.         With .Controls.Add(Type:=msoControlButton)
  12.             .Caption = "跨列居中"                   ' 标题
  13.             .BeginGroup = True                      ' 分类,添加分隔线
  14.             .OnAction = "跨列居中"                  ' 指定处理过程
  15.         End With
  16.     End With
  17. End Sub

复制代码
上面两个放到  thisworkbook 里面
  1. Sub 跨列居中()
  2.     Selection.HorizontalAlignment = xlCenterAcrossSelection
  3. End Sub
复制代码
这一个放到模块里面

跨列居中右键菜单建立.rar (9 KB, 下载次数: 25)
发表于 2012-1-9 14:00 | 显示全部楼层    本楼为最佳答案   
本帖最后由 sunjing-zxl 于 2012-1-9 14:01 编辑

  1. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  2.     With Application.CommandBars("cell")
  3.         .Reset  
  4.         End With
  5. End Sub
  6. Private Sub Workbook_Open()
  7.     ' 单元格区域右键菜单
  8.     With Application.CommandBars("cell")
  9.         .Reset
  10.         ' 添加控件
  11.         With .Controls.Add(Type:=msoControlButton)
  12.             .Caption = "跨列居中"                   ' 标题
  13.             .BeginGroup = True                      ' 分类,添加分隔线
  14.             .OnAction = "跨列居中"                  ' 指定处理过程
  15.         End With
  16.     End With
  17. End Sub

复制代码
上面两个放到  thisworkbook 里面
  1. Sub 跨列居中()
  2.     Selection.HorizontalAlignment = xlCenterAcrossSelection
  3. End Sub
复制代码
这一个放到模块里面

跨列居中右键菜单建立.rar (9 KB, 下载次数: 25)
回复

使用道具 举报

 楼主| 发表于 2012-1-9 14:25 | 显示全部楼层
谢谢,好快的速度啊,几分钟就解决问题了
回复

使用道具 举报

发表于 2012-1-9 14:39 | 显示全部楼层
2楼的是专家啊!!!!!
回复

使用道具 举报

发表于 2014-5-28 15:45 | 显示全部楼层
好好学习,谢谢楼主
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-17 04:54 , Processed in 0.271984 second(s), 12 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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