ActiveSheet.UsedRange.Columns.Count - 8是什么意思? [英] ActiveSheet.UsedRange.Columns.Count - 8 what does it mean?

查看:689
本文介绍了ActiveSheet.UsedRange.Columns.Count - 8是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vba中,ActiveSheet.UsedRange.Columns.Count - 8是什么意思?

what does ActiveSheet.UsedRange.Columns.Count - 8 mean in vba?

vba如何知道usedRange?

How does vba know the usedRange?

推荐答案

以下是 UsedRange MSDN参考):


每个Worksheet对象都有一个UsedRange属性,它返回一个表示正在使用的工作表区域的Range对象。 UsedRange属性表示工作表中最远的左上角和最远的右下方非空格单元格所描述的区域,并且包含之间的所有单元格。

Every Worksheet object has a UsedRange property that returns a Range object representing the area of a worksheet that is being used. The UsedRange property represents the area described by the farthest upper-left and farthest lower-right nonempty cells in a worksheet and includes all cells in between.

所以基本上是这样的:


  1. .UsedRange >绘制一个包围内部最外层单元格的框。

  2. .Columns - >选择这些单元格

  3. .Count - >返回与该列中有多少列相对应的整数

  4. - 8 - >从前一个整数中减去8。

  1. .UsedRange -> "Draws" a box around the outer-most cells with content inside.
  2. .Columns -> Selects the entire columns of those cells
  3. .Count -> Returns an integer corresponding to how many columns there are (in this selection)
  4. - 8 -> Subtracts 8 from the previous integer.

我假设VBA通过查找具有最低和最高索引值的非空单元格来计算UsedRange。

I assume VBA calculates the UsedRange by finding the non-empty cells with lowest and highest index values.

最有可能的是,您收到错误,因为您的范围内的行小于3,因此返回的数字为负数。

Most likely, you're getting an error because the number of lines in your range is smaller than 3, and therefore the number returned is negative.

这篇关于ActiveSheet.UsedRange.Columns.Count - 8是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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