You would simply change this line to change the = to LIKE and to add * Wildcards like so
Change original:
Formula:
If C.Value = "Other grades include: AU, AUX DX, FEX, I, IP, P, PS, S, SX, U, UX" Then
to updated:
Formula:
If C.Value Like "*Other grades include:*" Then
Line above says if any contains the words "Other grades include:" then proceed to merge
You can remove the wildcard from the front if you know the cells searching will always start with the phrase. Then wild card will pick up at the end.
You can also do this for the other if statement lines.
Full code modified:
Sub merge_cells(wb)
Dim ws As Worksheet
Dim C As Range
For Each ws In Sheets
For Each C In ws.Range("a2:a" & ws.Range("A" & Rows.Count).End(xlUp).Row)
On Error GoTo 10
If C.Value Like "*Other grades include:*" Then
C.Select
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 3)).Merge
ActiveCell.Select
End If
If C.Value Like "*Data reflect grades posted as of*" Then
C.Select
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 3)).Merge
ActiveCell.Select
End If
If C.Value Like "*Report produced by the Office of*" Then
C.Select
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 3)).Merge
ActiveCell.Select
End If
Next
10
Next
End Sub
Bookmarks