Macro won't do anything!

junebug

Board Regular
Joined
Apr 4, 2003
Messages
110
Hi,
Why won't this work? It doesn't seem to do anything.
What I am trying to do is look down column C starting at row 14 and if the entry ZZ.Coupon is there than offset 0,-1 to B and copy the date the entry was made and paste that date into AA12. If it is found then stop macro.

Sub FindCoupon()
Dim cell As Range
For Each cell In Range("c14", Range("c14").End(xlDown))
If cell = "ZZ. Coupon" Then
cell.Offset(0, -1).Copy
Range("aa12").PasteSpecial (xlPasteValues)
End If
Exit Sub
Next
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try moving the Exit Sub up before the End If. At the moment it exits the loop after testing the first cell.
 
Upvote 0
I just tried this and it worked fine. Do you actaully have a cell with ZZ. Coupon in it including the single space after the period?

Code:
Sub FindCoupon()
Dim cell As Range
For Each cell In Range("c14", Range("c14").End(xlDown))
    If cell = "ZZ. Coupon" Then
        cell.Offset(0, -1).Copy
        Range("aa12").PasteSpecial (xlPasteValues)
        Exit Sub
    End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,576
Messages
6,120,350
Members
448,956
Latest member
Adamsxl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top