Excel精英培训网

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

[已解决]如何确定VBA要操作的单元格不在数组或者透视表范围内

[复制链接]
发表于 2014-1-4 10:35 | 显示全部楼层 |阅读模式

众所周知,有两种单元格的内容是不允许被改变的,不管是手动改变还是VBA改变,一种是数组范围内的单元格,另一种是透视表内的单元格。

假如说现在要操作的单元格地址是A6,那么如何确定A6单元格是否在数组范围内以及是否在透视表的范围内。
如何确定要操作的单元格不在数组或者透视表范围内.rar (4.04 KB, 下载次数: 7)

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2014-1-4 10:40 | 显示全部楼层
回复

使用道具 举报

发表于 2014-1-4 10:41 | 显示全部楼层
Range.HasArray 属性
如果指定单元格属于数组公式,则该属性值为 True。
回复

使用道具 举报

发表于 2014-1-4 10:42 | 显示全部楼层
QQ截图20140104104307.jpg
回复

使用道具 举报

发表于 2014-1-4 10:45 | 显示全部楼层
参观一下
回复

使用道具 举报

发表于 2014-1-4 10:46 | 显示全部楼层
  1.     With Sheet3.Range("a6")
  2.         MsgBox .PivotCell Is Nothing
  3.         If Not .PivotCell Is Nothing Then
  4.             MsgBox .PivotCell.PivotTable.Name
  5.         End If
  6.     End With
  7.     With Sheet4.Range("a6")
  8.         If .HasArray Then
  9.             MsgBox .FormulaArray
  10.         End If
  11.     End With
复制代码
回复

使用道具 举报

发表于 2014-1-4 10:48 | 显示全部楼层    本楼为最佳答案   
  1.     With Sheet3.Range("a6")
  2.         MsgBox .PivotCell Is Nothing
  3.         If Not .PivotCell Is Nothing Then
  4.             MsgBox .PivotCell.PivotTable.Name
  5.         End If
  6.     End With
  7.     With Sheet4.Range("a6")
  8.         If .HasArray Then
  9.             MsgBox .CurrentArray.Address
  10.         End If
  11.     End With
复制代码
是数组后,用currentarray属性更好了。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-26 03:49 , Processed in 0.289873 second(s), 9 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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