Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-06-2016, 11:38 AM
ntbluez ntbluez is offline Date/Time Entry Windows 7 32bit Date/Time Entry Office 2013
Novice
Date/Time Entry
 
Join Date: Mar 2016
Posts: 1
ntbluez is on a distinguished road
Default Date/Time Entry

I'm trying to write excel vba and result is half-way working.


Its intention is to enter a date/timestamp in column C for respective row in column B. This occurs when clicking on any cell in column B. It is suppose to do this for columns D and E where E is the date/time entry for any cell clicked on in column D. EXAMPLE... If I click on cell B5, date/time stamp should appear in C5. If I click on cell D20, a date/timestamp should appear in C20. I hope this helps you to understand.***ALSO, Top Row is a lable, like A1 has word Task#, B1 has word like StepsToDo, C1 has word like Time4Steps,... I want Top Row to not accept any new text - protected ***.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  
  Dim iRange As Range
  If Target.Cells.Count <> 1 Then Exit Sub
  Set iRange = Intersect(Target, Range("B:B"))
  If iRange Is Nothing Then Exit Sub
  Application.EnableEvents = False
  Range("C" & Target.Row).Value = Now()
  Application.EnableEvents = True

Dim xRange As Range
 If Target.Cells.Count <> 1 Then Exit Sub
  Set xRange = Intersect(Target, Range("D:D"))
  If xRange Is Nothing Then Exit Sub
  Application.EnableEvents = False
  Range("E" & Target.Row).Value = Now()
  Application.EnableEvents = True
     
End Sub
Reply With Quote
 

Tags
date/time, vba code



Similar Threads
Thread Thread Starter Forum Replies Last Post
Day date and time cell display markg2 Excel 2 02-11-2015 06:57 AM
Date/Time Entry date & time of last time a recent file was used pgeorgilas Word 1 10-31-2014 08:59 AM
Date/Time Formula for Entry level XL user talon1driver Excel 2 09-18-2014 02:32 PM
Count the common time period (month) between two date period of time Barni Excel 6 08-15-2014 07:52 AM
Date/Time Entry Sent emails all have same date/time?? Confused Outlook 3 01-07-2011 07:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft