English 中文(简体)
Excel Macro:是否能够找到一个工作桌的罗高和哥伦索?
原标题:Excel Macro: is it possible to find Row heights and Column widths of a worksheet?

是否有任何办法在一份Excel板片中发现RodWS的高度从1到50,以及COLUMNS从A到Z的宽度,而没有人工点击和写下答案?

增 编

Michael。

最佳回答

加入:

Range("A1:A50").Height        height of range
Range("A:Z").Width            width of range
Range("A1:A50").Rows.Count    number or rows in range
Range("A3").Height            height of A3 cell
Range("A3").Width             width of A3 cell
问题回答

在Excel VBA中,你可以使用这样的东西:

Range("A1:A50").Height  

以及

Range("A:Z").Width

在Excel vba,通过使用浏览器,获得浏览量高的产出是容易的。 高地财产:

Sub outputRowHeight()
    Dim i As Integer

    For i = 1 To 50
         Debug.Print Rows(i).Address & " is : " & Rows(i).Height
    Next i

End Sub

在宽度一栏中,我们使用一栏、宽度财产。 这是一个小小小小trick,因为你可以通过字母字母直拨,因此我们需要使用该指数:

Sub outputColumnWidths1()
    Dim i As Integer

    For i = 1 To 26  26th letter is Z
            Debug.Print Columns(i).Address & " is : " & Columns(i).Width
    Next i

End Sub

如果你想要避免知道信件的索引,你可以使用声明,在你离开范围后退席:

Sub outputColumnWidths2()
    Dim i As Integer

    For i = 1 To 99  using 99 as arbitrary high end number
        If Columns(i).Address <> "$AA:$AA" Then
            Debug.Print Columns(i).Address & " is : " & Columns(i).Width
        Else  once we get outside of A-Z, we want to end.
            Exit For
        End If
    Next i

End Sub

这将产生与第一个例子相同的结果,但你可以将其扩大到你想要达到的许多栏目,即放弃其编号,以及你不想评价的第一个栏目。

希望这一帮助!





相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签