Hey Guys
I'm hoping you can assist me with a Macro. I have absolutely NO experience with Macro's so if you can give me as much help as possible that would be great.
In regards to the attached document, I would like the cells in Row 3 to record the time when the cells in Row 4 are changed. For example, when "1000" is entered into cell B5 at 10:00pm, I want B3 to change to "22:00". When C5 changes, C3 with show the time of change. So if there is a way to have this for each of the columns B:H.
Also, I would like a time of finish inserted into Row 40. So when the Value in Cell 39 changes from "NO" to "YES", I would like the cell underneath in Row 40 to show the time that change happens.
If anyone could provide me with a Macro to help me with this, I would appreciate it. Also, if you could give me any information/instruction on how to use the Macro that would be fantastic. Thank you for all your help!
Regards,
Regan
Try this,
Right Click the tab "Joes Sheet" then click View Code.
In the resulting window paste all of this code
Private Sub Worksheet_Change(ByVal Target As Range) Dim isect As Range Application.EnableEvents = False On Error GoTo ExitLine Set isect = Intersect(Target, Range("B5:H5")) If Not isect Is Nothing Then If Target = "" Then Target.Offset(-2, 0) = "" Else Target.Offset(-2, 0) = Format(Now(), "hh:mm") End If End If Set isect = Intersect(Target, Range("B39:H39")) If Not isect Is Nothing Then Target.Offset(1, 0) = Format(Now(), "hh:mm") End If Set isect = Nothing ExitLine: Application.EnableEvents = True On Error GoTo 0 End Sub
Hope this helps
If you need any further information, please feel free to ask further
However
If this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody!
Also
If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.
Last edited by Marcol; 04-26-2010 at 06:29 AM. Reason: Added Dons' comment to code
Marcol, I confess I've not read the question but I would make the point that though not vital in this instance (in terms of avoiding perpetual loop) you should toggle events when altering active sheet content via the Change event
(ie the act of altering content will in turn re-invoke the change event - needlessly in this instance however were the altered cell within the range of interest you would end up in a perpetual loop).
And if you toggle events you should add an error handler "just in case" so as to ensure events are reactivated irrespective of outcome.
Last edited by DonkeyOte; 04-26-2010 at 06:11 AM. Reason: removed edit - misread code :oops:
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Hi Don,
Point taken, I'm working on a time limited machine at the moment,( I'm away from home)
To much a of a rush agianst available time.
I've amended the code in Post #2
Don't think it needs an error handler, but will check later.
EDIT
Okay, still in a rush, I've added belt and braces version
Cheers
Last edited by Marcol; 04-26-2010 at 06:26 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks