简体   繁体   中英

excel VBA - searching single column for a range of values and selecting the rows the values are in

Example:

Column A has numerical values or strings in each cell, values of 0 - 15000 are listed, i need to find and select each row containing numerical values and add a border to the top of the row.

Putting a border on top of each cell in the row was easy, but trying to search the column for numerical values has me stumped.

any help would be great.

Give this a try:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM