Add date to column when another cell is updated

Hydestone

Board Regular
Joined
Mar 29, 2010
Messages
137
I want the date in column F to update when I update information in column G.

This piece of VBA isn't working for me...any ideas on how to rewrite it?

Case Is = 7
If Target.Offset(, -1) = "" Then Target.Offset(, -1) = Date

Here is entire code on sheet.

Code:
Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A:A,C:C")) Is Nothing Then Exit Sub
    Dim LastRow As Long
    LastRow = Sheets("Open").Range("C" & Rows.Count).End(xlUp).Row + 1
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    Select Case Target.Column
        Case Is = 1
            If Target = "X" And Target.Offset(, 10) = "" Then
                Target.Offset(0, 10) = Date
                Rows(Target.Row).EntireRow.Copy Sheets("Closed").Cells(Sheets("Closed").Rows.Count, "A").End(xlUp).Offset(1, 0)
            ElseIf Target = "" Then
                Rows(Target.Row).EntireRow.Copy Sheets("Open").Cells(LastRow, 1)
            End If
        Case Is = 3
            If Target.Offset(, -1) = "" Then Target.Offset(, -1) = Date
        Case Is = 7
            If Target.Offset(, -1) = "" Then Target.Offset(, -1) = Date
    End Select
    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
End Sub
 
Last edited by a moderator:
Something funky is going on...the code works, then all of a sudden it doesn't. The copy items when closed worked, but now doesn't. Also, populating the date when something entered in column C no longer works. Here is current code:
Code:
Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A:A,C:C,G:G")) Is Nothing Then Exit Sub
    Dim LastRow As Long
    LastRow = Sheets("Open").Range("C" & Rows.Count).End(xlUp).Row + 1
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    Select Case Target.Column
        Case Is = 1
            If Target.CountLarge > 1 Then Exit Sub
            If Target = "X" And Target.Offset(, 10) = "" Then
                Target.Offset(0, 10) = Date
                Rows(Target.Row).EntireRow.Copy Sheets("Closed").Cells(Sheets("Closed").Rows.Count, "A").End(xlUp).Offset(1, 0)
            ElseIf Target = "" Then
                Rows(Target.Row).EntireRow.Copy Sheets("Open").Cells(LastRow, 1)
            End If
        Case Is = 3
            If Target.Offset(, -1) = "" Then Target.Offset(, -1) = Date
        Case Is = 7
            If Target.Offset(, -1) = "" Then Target.Offset(, -1) = Date
    End Select
    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
End Sub
 
Last edited by a moderator:
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Are you copy/pasting into multiple cells, or will you only update cell by cell?
 
Upvote 0
I update the lines one at a time...no copying down or copy/pasting multiples.

I delete multiple at a time.
 
Upvote 0
I would normally put that line as the very first line of code, but as long as it's before the
Code:
With Application
line, all should be ok.
 
Upvote 0
OK, I moved it up to the 3rd line.

If I wanted to remove the functionality of copying stuff to the Open worksheet, which lines could I safely remove?
Code:
  Option Compare TextPrivate Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Intersect(Target, Range("A:A,C:C,G:G")) Is Nothing Then Exit Sub
[COLOR=#ff0000]    Dim LastRow As Long[/COLOR]
[COLOR=#ff0000]    LastRow = Sheets("Open").Range("C" & Rows.Count).End(xlUp).Row + 1[/COLOR]
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    Select Case Target.Column
        Case Is = 1
            If Target = "X" And Target.Offset(, 10) = "" Then
                Target.Offset(0, 10) = Date
                Rows(Target.Row).EntireRow.Copy Sheets("Closed").Cells(Sheets("Closed").Rows.Count, "A").End(xlUp).Offset(1, 0)
[COLOR=#ff0000]            ElseIf Target = "" Then[/COLOR]
[COLOR=#ff0000]                Rows(Target.Row).EntireRow.Copy Sheets("Open").Cells(LastRow, 1)[/COLOR]
            End If
        Case Is = 3
            If Target.Offset(, -1) = "" Then Target.Offset(, -1) = Date
        Case Is = 7
            If Target.Offset(, -1) = "" Then Target.Offset(, -1) = Date
    End Select
    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
End Sub
 
Upvote 0
Removing the red lines should be ok
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top