vendredi 20 novembre 2015

Display message box only if cells start with ECH

This is a snip of a larger piece of code--I want it to search the rows of my spreadsheet and display the message box only when the cells in columns R and T both begin with ECH. Currently the code works just fine, but it only displays if the cells value is "ECH".

I've found a couple similar questions on the forum, but wasn't sure how to directly apply them to my situation. If somebody could recommend how to specify that I want only the cells that begin with "ECH" that'd be great. Thanks!

Dim i As Long
i = 2
Do While Cells(i, "F").Value <> ""
  If Cells(i, "R").Value = "ECH" And Cells(i, "T").Value = "ECH" Then
    MsgBox ("YES")
    Else
    MsgBox ("NO")
  End If
  i = i + 1
Loop

Aucun commentaire:

Enregistrer un commentaire