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:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
This line here is causing you problems:
Code:
[COLOR=#333333]If Intersect(Target, Range("A:A,C:C")) Is Nothing Then Exit Sub[/COLOR]
This says, if the cell being updated is not in columns A or C, then exit the sub (and do nothing).
So you will never catch changes in column G.
 
Last edited:
Upvote 0
Make this change
Code:
    If Intersect(Target, Range("A:A,C:C[COLOR=#ff0000],G:G[/COLOR]")) Is Nothing Then Exit Sub
 
Upvote 0
One other bug that is popping up for me. When an item is closed out, I put an X in column A, which copies / archives the row data to a different sheet. In order to tidy up the list of items, I filter and select all rows with an X in column A, then select view special > visible cells only, then delete the rows. When doing so, I get a run time debug error code 13 that bring me to this:

If Target = "X" And Target.Offset(, 10) = "" Then

Any ideas on what is up?
 
Upvote 0
If you only update the cells one by one, rather than copy/pasting data add this line as the first line
Code:
If Target.CountLarge>1 then Exit Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
Sorry...one more thing. That works, but after I select multiple rows and delete them, the VBA stops working. Any way to restart it, after I delete the rows...other than existing the workbook and re-opening it?
 
Upvote 0
Where did you put the last line of code that Fluff gave you?
Make sure that you put it near the top, before the line of code that disables events (otherwise, events will be shut off, and the code will not be triggered until you exit and re-open).
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

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