ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Place a date in another cell only if adjacent cell = "X" (https://www.excelbanter.com/excel-programming/428676-place-date-another-cell-only-if-adjacent-cell-%3D-x.html)

JOSEPH WEBER

Place a date in another cell only if adjacent cell = "X"
 
How do I modify this code to place a date in the adjacent cell only if that
cell equals a capital x?



Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("c2:c50000"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, 1).ClearContents
Else
With .Offset(0, 1)
.NumberFormat = "mm/dd/yyyy"
.Value = Date
End With
End If
Application.EnableEvents = True
End If
End With
End Sub



Mike H

Place a date in another cell only if adjacent cell = "X"
 
You have an answer in your other thread

"JOSEPH WEBER" wrote:

How do I modify this code to place a date in the adjacent cell only if that
cell equals a capital x?



Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("c2:c50000"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, 1).ClearContents
Else
With .Offset(0, 1)
.NumberFormat = "mm/dd/yyyy"
.Value = Date
End With
End If
Application.EnableEvents = True
End If
End With
End Sub




All times are GMT +1. The time now is 12:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com