Macro Script needed

kshitij_dch

Active Member
Joined
Apr 1, 2012
Messages
362
Office Version
  1. 365
  2. 2016
  3. 2007
Platform
  1. Windows
hi all ,

I have a column AI in which dates are given in (MM/DD/YYYY)

I am looking for a macro which selects all the dates in Column AI apart from today's date .

If anyone can help !!!
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
What does this mean:
"apart from today's date ."

Does that mean any date which is "not" todays date?

Select them and do what?
<strike></strike>
 
Upvote 0
yes , all the date which is not today's date ,

Select them and against the date i need to write "coupons Given" (Next Cell)

Example :

[TABLE="width: 496"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD="align: right"]12/10/2015[/TD]
[TD] Coupons Given[/TD]
[/TR]
[TR]
[TD="align: right"]10/10/2016[/TD]
[TD] Coupons Given[/TD]
[/TR]
[TR]
[TD="align: right"]08/26/2017[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]08/22/2017[/TD]
[TD] Coupons Given[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Try this:
Code:
Sub Test()
Application.ScreenUpdating = False
Dim c As Range
    For Each c In Range("AI1:AI" & Cells(Rows.Count, "AI").End(xlUp).Row)
        If IsDate(c.Value) Then If c.Value <> Date Then c.Offset(, 1).Value = "Coupons Given"
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
thank you it is working like a charm ,

One more question ,


if in case cell is blank in column AI then i need to write "No refund" against that blank cell. ???
 
Upvote 0
If AI is empty you want AJ to say "No refund" is that what you want?
thank you it is working like a charm ,

One more question ,


if in case cell is blank in column AI then i need to write "No refund" against that blank cell. ???
 
Upvote 0
Try this:
Code:
Sub Test()
'Modified 8-26-17 9:11 AM EDT
Application.ScreenUpdating = False
Dim c As Range
    For Each c In Range("AI1:AI" & Cells(Rows.Count, "AI").End(xlUp).Row)
        If IsDate(c.Value) Then
            If c.Value <> Date Then c.Offset(, 1).Value = "Coupons Given"
        ElseIf c.Value = "" Then c.Offset(, 1).Value = "No Refund"
        End If
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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