【发布时间】:2011-12-21 20:05:53
【问题描述】:
我刚刚写了一个小的 VBA 函数,如下所示。作为函数输出,我想得到 Range
Public Function selectRows(col As String) As Range
Dim begin, fini As Integer
Set TopCell = Cells(1, col)
Set BottomCell = Cells(Rows.Count, col)
If IsEmpty(TopCell) Then Set TopCell = TopCell.End(xlDown)
If IsEmpty(BottomCell) Then Set BottomCell = BottomCell.End(xlUp)
begin = TopCell.Row
fini = BottomCell.Row
Set selectRows = Activesheet.Range(col & begin & ":" & col & fini)
End Function
然后在尝试设置输出 =Range(...) 时出现类型不匹配错误
你能帮我解决这个问题吗,谢谢提前
【问题讨论】:
-
函数返回值。但是你没有在这个函数中设置
selectRows。