【发布时间】:2017-11-25 00:14:01
【问题描述】:
我希望能够为我正在搜索的列标题下的第二个单元格设置一个范围到列的底部。我不想选择整个列,而只是从第二个单元格开始使用的范围(不包括标题)。
我能够编写一些代码来查找标题,但是在将单元格地址(字符串)转换为范围然后为该列的其余部分选择使用的范围时遇到了一些问题。这是我目前的情况:
Sub colRange()
Dim ws As Worksheet
Dim hostCellRange As Range
Set ws = Worksheets("Sheet1")
With ws
With .Range("A1", .Cells(1, .Columns.Count).End(xlToLeft))
Set cfind = .Find(What:="host", LookIn:=xlValues, lookat:=xlWhole)
If Not cfind Is Nothing Then
hostCell = cfind.Address
Set hostCellRange = ws.Range(hostCell)
End If
End With
End With
End Sub
感谢您的帮助!
【问题讨论】:
-
你的范围内会有空白单元格吗?