vendredi 16 février 2018

Excel VBA Add Border Based on Beginning of String Change

I have a worksheet with 11 columns containing various logistics information. Column B Item # consists of alphanumeric digits that start with PK or RM. I need to place a black border that spans the length of the whole worksheet between the last cell (column B "Item Number") beginning with PK and first cell with RM (bottom border for PK cell or Top border for RM cell). I then need to do a two layer sort (sorting by Column H "Due Date" and then Column B "Item Number"). But I need each sort to be split between the bold line.

I've searched through Google and StackOverFlow and cannot find the answer to this situation although there are similar border questions. I appreciate your time.

This is the code I was working on for the first black border step:

Sub CondUnderline()
'
' CondUnderline Macro
'
'
    range("B").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
        Formula1:="=""RM"""
    With Selection.FormatConditions(1).Borders(xlTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
End Sub

I'm a VBA newbie and mainly have been using the macro recorder and the web to fill in knowledge gaps.

Aucun commentaire:

Enregistrer un commentaire