Why this simple macro doesn't work?

  • Thread starter Thread starter 71marco71
  • Start date Start date
7

71marco71

Dear friends
Someone can tell me why this simple macro doesn’t work?

Public Sub Pippo()
For j = 2 To 50
If Cells(j, 2) = "" Then
Exit For
End If
If Cells(j, 2) = "COPPIA RU*" Then
Cells(j, 4).Value = Cells(j, 4) * 2
End If
Next j
End Sub

Thank you very much for your help

I have attached a exampl

Attachment filename: pippo.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=43382
 
Hi Marco,

How's the sun?

To do pattern matching in VBA you need to use Like, such as

Public Sub Pippo()
For j = 2 To 50
If Cells(j, 2) = "" Then
Exit For
End If
If Cells(j, 2) Like "COPPIA RU*" Then
Cells(j, 4).Value = Cells(j, 4) * 2
End If
Next j
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Public Sub Pippo()
For j = 2 To 50
If Cells(j, 2) = "" Then
Exit For
End If
If Instr(1,Cells(j, 2),"COPPIA RU",vbTextCompare) = 1 Then
Cells(j, 4).Value = Cells(j, 4) * 2
End If
Next j
End Sub
 
Back
Top