Sub ReplaceText()
Dim lastRow As Long
Dim i As Long
Dim strC As String
Dim strD As String
lastRow = Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To lastRow
strC = Cells(i, 3).Value 'C列の文字列を取得
strD = Cells(i, 4).Value 'D列の文字列を取得
If strC = "進学" And InStr(strD, "大学") > 0 Then 'C列が「進学」で、D列に「大学」が含まれる場合
Cells(i, 2).Value = "本学大学院" 'B列を「本学大学院」に修正
End If
Next i
End Sub
※ChatGPT にやってもらいました(笑)