lundi 19 octobre 2020

Problems with an if statement in For loop

I am trying to insert an If statement in a For loop but keep getting errors. Code is :

For i = 3 To lastRow
    If Range("Q" & i).Value = "Data confirmed" Then Range("Q" & i).Value = ""
    Else
    sh.Cells(i, "Q").Hyperlinks.Add Anchor:=sh.Cells(i, "Q"), Address:="", _
    SubAddress:="", TextToDisplay:="Click To Save"
    End If
    
Next i

When the cell contains the value "Data Confirmed" , no hyperlink should be included and the value should be "" When there is no "Data confirmed" in the cell, a hyperlink should pop up ( see code after the "ELSE")

What am i doing wrong?

Aucun commentaire:

Enregistrer un commentaire