Excel精英培训网

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

[已解决]VBA如何把所有合并单元格取消合并

[复制链接]
发表于 2017-10-28 07:41 | 显示全部楼层 |阅读模式
本帖最后由 laoau138 于 2017-10-28 09:45 编辑

VBA如何把所有合并单元格取消合并



最佳答案
2017-10-28 09:33
  1. Sub aaa()
  2. Dim rng As Range
  3. Application.FindFormat.MergeCells = True
  4. Application.ScreenUpdating = False
  5. Set rng = Cells.Find(What:="", LookIn:=xlFormulas, LookAt:=xlPart, SearchFormat:=True)
  6. Do
  7.   With rng.MergeArea
  8.     .MergeCells = False
  9.     .Value = rng
  10.   End With
  11.   Set rng = Cells.Find(What:="", After:=rng, SearchFormat:=True)
  12.   If rng Is Nothing Then Exit Do
  13. Loop
  14. Application.ScreenUpdating = True
  15. End Sub
复制代码
VBA如何把所有合并单元格取消合并.png

VBA如何把所有合并单元格取消合并.rar

7.22 KB, 下载次数: 13

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2017-10-28 09:33 | 显示全部楼层    本楼为最佳答案   
  1. Sub aaa()
  2. Dim rng As Range
  3. Application.FindFormat.MergeCells = True
  4. Application.ScreenUpdating = False
  5. Set rng = Cells.Find(What:="", LookIn:=xlFormulas, LookAt:=xlPart, SearchFormat:=True)
  6. Do
  7.   With rng.MergeArea
  8.     .MergeCells = False
  9.     .Value = rng
  10.   End With
  11.   Set rng = Cells.Find(What:="", After:=rng, SearchFormat:=True)
  12.   If rng Is Nothing Then Exit Do
  13. Loop
  14. Application.ScreenUpdating = True
  15. End Sub
复制代码

评分

参与人数 1 +9 收起 理由
laoau138 + 9 来学习

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2017-11-29 19:46 | 显示全部楼层
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-6 10:11 , Processed in 0.246374 second(s), 14 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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