Need macro to execute when a date is put in a column

sspatriots

Well-known Member
Joined
Nov 22, 2011
Messages
569
Office Version
  1. 365
Platform
  1. Windows
Hi,

I want to use the code below that moves a row of information to another worksheet when the word "Done" is put into this one column. I would like to use it to do the same thing, but instead of the word "Done", I want the code to execute when any date is put in that column.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
If Target = "Done" Then
Target.EntireRow.Copy Sheets(Range("A" & Target.Row).Value).Cells(Sheets(Range("A" & Target.Row).Value).Rows.Count, "A").End(xlUp).Offset(1, 0)
End If
End Sub



I've played with this for the last hour and googling the If Target statements, but nothing will work. This is not for the same spreadsheet my other post was for. Trying to optimize about 8 spreadsheets for this company I just started working at. Any assistance would be much appreciated.


Steve
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
    If IsDate(Target) Then
        Target.EntireRow.Copy Sheets(Range("A" & Target.Row).Value).Cells(Sheets(Range("A" & Target.Row).Value).Rows.Count, "A").End(xlUp).Offset(1, 0)
    End If
End Sub
 
Upvote 0
Try:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
    If IsDate(Target) Then
        Target.EntireRow.Copy Sheets(Range("A" & Target.Row).Value).Cells(Sheets(Range("A" & Target.Row).Value).Rows.Count, "A").End(xlUp).Offset(1, 0)
    End If
End Sub
Thank you!!!

That does exactly as I had hoped it would. Is there anything I can add to it to make the top row be selected after I make an entry? I added the 02/28/2022 date and it bounced up to row three and highlighted it.

Capture1.PNG
 
Upvote 0
Correction to my question. Should have read: Is there anything I can add to it to make the row near the top not be selected after I make an entry?

Is there anything I can add to it to make the top row be selected after I make an entry?
 
Upvote 0
Which row do you want selected?
 
Upvote 0
If I make a date entry in that column anywhere, I would like it to stay at that active cell where the date is placed.
 
Upvote 0
Try:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
    If IsDate(Target) Then
        Target.EntireRow.Copy Sheets(Range("A" & Target.Row).Value).Cells(Sheets(Range("A" & Target.Row).Value).Rows.Count, "A").End(xlUp).Offset(1, 0)
        Target.Select
    End If
End Sub
 
Upvote 0
Solution
You are very welcome. :)
 
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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