Todays date or static

bd1982

New Member
Joined
Oct 23, 2018
Messages
4
hello

I am trying to see if I can have column N populate todays date if column A is populated but not if column M is also populated. I have searched and found two VBA instructions which do one or the other but being (very) new to VBA I dont know how to make them work together, or even whether they are correct. Below is an example of my table, what I want is for the outstanding date to be todays date if requisition number is present but to not change if status shows as closed, this would allow me to then calculate the days a position has been open for.


Requisition Number Requisition Date Outstanding Vacancies Status Outstanding DateClosed Datedays open
11010/01/2018 closed18/10/2018 281
11107/06/20183 18/10/2018 133
11207/06/20181 18/10/2018 133
11311/02/2018 closed18/10/2018 249
11406/06/20184 18/10/2018 134
<colgroup><col width="138" style="width: 104pt; mso-width-source: userset; mso-width-alt: 5046;"> <col width="123" style="width: 92pt; mso-width-source: userset; mso-width-alt: 4498;"> <col width="98" style="width: 74pt; mso-width-source: userset; mso-width-alt: 3584;"> <col width="64" style="width: 48pt;"> <col width="75" style="width: 56pt; mso-width-source: userset; mso-width-alt: 2742;" span="3"> <tbody> </tbody>

The code I have is below, (appologies this is all very new to me)

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim A As Range, B As Range, Inte As Range, r As Range
    Set A = Range("A:A")
    Set Inte = Intersect(A, Target)
    If Inte Is Nothing Then Exit Sub
    Application.EnableEvents = False
        For Each r In Inte
            r.Offset(0, 13).Value = Date
        Next r
    Application.EnableEvents = True
    
    Set A = Range("m:m")
    Set Inte = Intersect(A, Target)
    If Inte Is Nothing Then Exit Sub
    Application.EnableEvents = False
        For Each r In Inte
            r.Offset(0, 1).Value = Date
        Next r
    Application.EnableEvents = True
End Sub

If someone could point me in the right direction that would be great.

Thanks in advance
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Would you elaborate on this "if requisition number is present"?

Seems to me you want something like this:

If status is not "closed" and requisition number is present then
set outstanding date to today's date
End If
 
Upvote 0
hi

essentially I want to be able to start tracking the days a post has been outstanding from the time the requisition number is added to the time the status is set to closed so what you have put would be right if the date "closed" was added remained static
 
Upvote 0
How about
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("A:A,M:M")) Is Nothing Then
      If Target.Column = 1 Then
         Target.Offset(, 13).Formula = "=today()"
      ElseIf Target.Column = 13 Then
         If LCase(Target.Value) = "closed" Then Target.Offset(, 1).Value = Date
      End If
   End If
End Sub
 
Upvote 0
Thanks, I'll try this and see if it sticks when I update the tacker tomorrow and let you know.

much appreciated.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,454
Messages
6,124,933
Members
449,195
Latest member
Stevenciu

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