Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBasic Macro Assistance Needed 1

Status
Not open for further replies.

debitmiser72

Technical User
Jan 29, 2008
2
I need help creating a macro in Excel that will enter the time in cell A1 when there is value in cell B1, and so forth down thru A50 when there is a value in B50. The time needs to be when the value was entered into the B-column and run only once.

Anyone have any ideas??
 



Use the Worksheet_Change event.

When the Target range object intersects with the COLUMN B range AND the corresponding row value in column A is empty, then assign NOW to that cell...
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Columns(2)) Is Nothing Then
        If Cells(Target.Row, "A").Value = "" Then _
            Cells(Target.Row, "A").Value = Now
    End If
End Sub
Right-click the sheet tab and paste into code window.



Skip,

[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top