3
Dim count As Integer
Dim myData As Workbook
Dim col As Integer, rng As Range, n#, b#
col = Selection.Column 'choose the column to count the values from
If Application.WorksheetFunction.CountA(Columns(col)) = 0 Then
MsgBox "You have selected a blank column"
n = 0
Else
Set rng = Intersect(Columns(col), ActiveSheet.UsedRange)
On Error Resume Next
b = rng.Cells.SpecialCells(xlCellTypeBlanks).count
n = rng.Cells.count - b - 1
On Error GoTo 0
Worksheets("sheet1").Select
而不是column.selection
指定列數來選擇Excel列,我需要能夠通過指定列編號或名稱來選擇列。我需要能夠在VBA
'列(1)=柱one'或'列( 「A」)=柱一個'現在設置你的'Dim col As Range'和'col = Col umns(1)' – 0m3r
運行時錯誤 - 對象變量或塊變量未設置 – 11user2614896
您需要使用'set col = Columns(1)'sry已清除,請告知我 – 0m3r