excel VBA - 在单列中搜索一系列值并选择值所在的行

时间:2014-04-08 17:08:40

标签: excel excel-vba vba

示例:

A列在每个单元格中都有数值或字符串,列出0到15000的值,我需要找到并选择包含数值的每一行,并在行的顶部添加一个边框。

在行中的每个单元格顶部放置边框很简单,但是尝试在列中搜索数值时,我感到很难过。

任何帮助都会很棒。

1 个答案:

答案 0 :(得分:0)

尝试一下:

Sub topHeavy()
    Dim N As Long, i As Long
    N = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To N
        If IsNumeric(Cells(i, 1).Value) And Cells(i, 1).Value <> "" Then
            With Cells(i, 1).EntireRow.Borders(xlEdgeTop)
                .LineStyle = xlContinuous
                .ColorIndex = 0
                .TintAndShade = 0
                .Weight = xlThin
            End With
        End If
    Next i
End Sub