【发布时间】:2015-08-30 18:56:11
【问题描述】:
尝试编写范围函数的并集
我得到“对象变量或未设置块”
我没有做对(我认为):
With Rng
UnionRange = Intersect(ws.UsedRange, Rng.EntireColumn)
End With
Sub iUnionRange()
Dim R As Range
'Check to see if the Function is working
Set R = UnionRange("Elements", Range("A1:D1, G1:G1, I1:K1"))
R.Select
End Sub
功能
Function UnionRange(shtName As String, Rng As Range) As Range
Set ws = ThisWorkbook.Sheets(shtName)
If Rng Is Nothing Then Exit Function
With ws.Rng
UnionRange = Intersect(ws.UsedRange, .EntireColumn)
End With
End Function
【问题讨论】: