在Excel VBA中复制时如何确定是否存在隐藏的列 [英] How to determine if there are hidden columns when copying in Excel VBA

查看:137
本文介绍了在Excel VBA中复制时如何确定是否存在隐藏的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说明的,我有一台Excel 2003工作簿,并且正在VBA中将一张纸的许多列复制到另一张纸.我不知道,有人在源工作表中隐藏了几列,并且弄乱了我如何处理目标工作表中的单元格.

As the title explains, I have an Excel 2003 workbook and I'm copying a number of columns of one sheet to another in VBA. Unknown to me, someone has hidden a few columns on the source sheet and it has messed up how I process the cells in the destination sheet.

我如何以编程方式确定:

How can I programmically determine:

  1. 如果有隐藏的列
  2. 哪些列是隐藏的?

谢谢!合资企业

推荐答案

对于 Range ,请检查

For a Range, check the Range.Hidden property.

MSDN的以下代码段是如何隐藏/取消隐藏行/列的一个很好的例子:

The following snippet from MSDN is a good example of how to hide/unhide a row/column:

 Worksheets("Sheet1").Columns("C").Hidden = True

您还可以使用 If 语句测试该值:

You can also test the value with an If statement:

 For ColCounter = 1 To 10
      If Columns("C").Hidden = True Then
           Columns("C").Hidden = False
      End If
 Next

这篇关于在Excel VBA中复制时如何确定是否存在隐藏的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆