0

我有下面的代码,用于从第 6 行向下选择 C ​​列中的非空白单元格。对于选择的每个单元格,我现在希望代码也选择该行的第 1 到第 10 列中的单元格 - 但我很挣扎!任何帮助都会很棒!

Sub EnquiryPrep()
Dim x As Integer
Dim rng As Range
With Sheets("Sheet 1")
LR = .Range("C" & Rows.Count).End(xlUp).Row
For Each cell In .Range("C6:C" & LR)
    If cell.Value <> "" Then
        If rng Is Nothing Then
            Set rng = (cell)
        Else
            Set rng = Union(rng, cell)
        End If
    End If
    Next cell
rng.Select
End With
End Sub
4

1 回答 1

0

也许只是

Sub EnquiryPrep()
Dim x As Integer
Dim rng As Range
With Sheets("Sheet 1")
LR = .Range("C" & Rows.Count).End(xlUp).Row
For Each cell In .Range("C6:C" & LR)
    If cell.Value <> "" Then
        If rng Is Nothing Then
            Set rng = cell.offset(, -2).resize(, 10)
        Else
            Set rng = Union(rng, cell.offset(, -2).resize(, 10))
        End If
    End If
    Next cell
rng.Select
End With
End Sub
于 2013-08-15T10:25:17.477 回答