Thread: date and time
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default date and time

This macro should do what you want...

Sub ApplyDate()
Dim X As Long
Dim LastDataCell As Long
LastDataCell = Cells(Rows.Count, 1).End(xlUp).Row
For X = 1 To LastDataCell
If Len(Cells(X, 1)) 0 And Len(Cells(X, 2)) = 0 Then
Cells(X, 2).Value = Now
Cells(X, 3).Value = 1
End If
Next
End Sub

Just one note on it... if there is already a date in Colum B, this macro
will leave it (and all other cells in the row) as is... it will only add
dates to that data not already having a date.

Rick



"Daniel M" wrote in message
...
I have a macro i need to run that fills in the date and time. For example I
have data in column A and i need to put the date and time in column B
everywhere there is data in column A. Date and time format needs to be
1/17/2008 6:30:00 PM.

In addition i need to add a 1 to column C when ever there is data in
column A.

Thanks.