ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why this simple macro doesn't work? (https://www.excelbanter.com/excel-programming/290543-why-simple-macro-doesnt-work.html)

71marco71[_8_]

Why this simple macro doesn't work?
 
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
--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Why this simple macro doesn't work?
 
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)

"71marco71 " wrote in message
...
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 example

Attachment filename: pippo.xls
Download attachment:

http://www.excelforum.com/attachment.php?postid=433823
---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

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 Instr(1,Cells(j, 2),"COPPIA RU",vbTextCompare) = 1 Then
Cells(j, 4).Value = Cells(j, 4) * 2
End If
Next j
End Sub

--
Regards,
Tom Ogilvy


"71marco71 " wrote in message
...
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 example

Attachment filename: pippo.xls
Download attachment:

http://www.excelforum.com/attachment.php?postid=433823
---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 07:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com