Macro to paste today's date on last column of specific rows?

karthick019

New Member
Joined
Jul 15, 2011
Messages
10
Hello Experts,

I have a situation where there are few rows for which I should paste date from Workings column to the last column of that Row.

Refer below example for clear understanding,

ID
1st Case
2nd Case
3rd Case
4th Case
5th Case



Working
A1
01/05/2016
15/06/2016
27/09/2016
27/09/2016
A2
04/03/2016
17/07/2016
23/07/2016
A3
08/05/201616/06/2016
29/07/2016
11/08/2016
A4
03/02/2016
27/09/2016
27/09/2016
A5
07/03/2016
06/04/2016
03/08/2016


As you could see in the above example, I need a macro that will paste the dates from Working Column to the respective last column of the row.

Please do let me know if you are still not clear on the question and I will try to explain better.

Would be very helpful if I could find a macro for this.

Thank you in advance.


Regards,
Karthick. S
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
What column is your "Working" column?
Is it column G or something else?
Does that ever change?

What row does your data start on?
Is the ID column always column A?
 
Upvote 0
EDIT:

Oh wow, I misread that and went totally backwards on this, trying to populate the working column from the last column with data, if the last date is today.
I think I need to get some morning caffeine!
 
Last edited:
Upvote 0
It appears to me that your "working" column is well to the right of your "Case" columns. If that is so, then perhaps this would do what you want.
Adjust the "J" values in my code to match your "working" column.

Code:
Sub CopyDate()  
  Dim c As Range
  
  For Each c In Range("J2", Range("J" & Rows.Count).End(xlUp))
    If IsDate(c.Value) Then c.End(xlToLeft).Offset(, 1).Value = c.Value
  Next c
End Sub
 
Last edited by a moderator:
Upvote 0
What column is your "Working" column?
Is it column G or something else?
Does that ever change?

What row does your data start on?
Is the ID column always column A?


Lets assume that my "working" Column is "Z"

I want the data's in Column Z to be pasted in their corresponding last column on the row (CTRL+LEFT from "Z") respectively.

Kindly let me know if I am clear enough.

I'm sorry but I am finding it difficult to explain the scenario.
 
Upvote 0
Take a look at Peter's solutions and see if it works for you.
 
Upvote 0
88x8GKav0.jpg


Can the above screenshot give you more clear view of the scenario? :(
 
Last edited:
Upvote 0
Note that I mentioned my original code was backwards, and have since removed it. Peter's original code got a little messed up. I am not sure why, but when posting code, sometimes it blends the first two lines of code together. I went back to his code and fixed it.

If your working column is Column Z, just edit Peter's code like this:
Code:
Sub CopyDate()

    Dim c As Range
  
    For Each c In Range("Z2", Range("Z" & Rows.Count).End(xlUp))
        If IsDate(c.Value) Then c.End(xlToLeft).Offset(, 1).Value = c.Value
    Next c
    
End Sub
If that doesn't work, please let us know exactly what is happening, and confirm that your date column are really blank, and not formulas returning nothing.
 
Last edited:
Upvote 0
Peter's original code got a little messed up. I am not sure why, but when posting code, sometimes it blends the first two lines of code together. I went back to his code and fixed it.
Thanks Joe. I often see that issue with other people's code but if mine was like that I think it is the first time ever it has happened to me. Quite surprised! Anyway, thanks again for the repair.
 
Upvote 0

Forum statistics

Threads
1,215,517
Messages
6,125,287
Members
449,218
Latest member
Excel Master

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