p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Excel VBA (http://p2p.wrox.com/forumdisplay.php?f=79)
-   -   populate status values for tracking action items (http://p2p.wrox.com/showthread.php?t=57932)

miracles May 15th, 2007 08:32 PM

populate status values for tracking action items
    I need help for the following.How do i achieve this result using vb(i m developing macros using excel)?Thanks alot in advanced:)
I need to populate the results in a new column called 'Action_Status_Update'

For example, Today is 16/05/07 in the month of May.I need to set the value for 'Action_Status_Update' , when the Action_Status='Open' for the next 3 month to 'Due Soon', so that i can send reminder email to the users to remind them that the action item is to be due soon.

Below is the result that i need to achieve.Thanks

[u]Action_Due_Date</u> [u]Action_Status </u> [u]Action_Status_Update</u>
Jan-07 Open Over Due
Jan-07 Closed Done
Feb-07 Open Over Due
Feb-07 Closed Done
Mar-07 Open Over Due
Mar-07 Closed Done
Apr-07 Open Over Due
Apr-07 Closed Done
May-07 Open Due Soon
May-07 Closed Done
Jun-07 Open Due Soon
Jun-07 Closed Done
Jul-07 Open Due Soon
Jul-07 Closed Done
Aug-07 Open Not Due Yet
Aug-07 Closed Done
Sep-07 Open Not Due Yet
Sep-07 Closed Done
Oct-07 Open Not Due Yet
Oct-07 Closed Done
Nov-07 Open Not Due Yet
Nov-07 Closed Done
Dec-07 Open Not Due Yet
Dec-07 Closed Done

allenm May 16th, 2007 02:47 PM

Not sure if you want to call the procedure or have it assigned to a button. I've created a button called Update_Button for the example. The due date would need to be an actual date field or the code won't work without some tweaking.

Assuming your detail starts in row 2, A1 is Action_Due_Date, A2 is Action Status, and Action_Status_Update is A3:
Private Sub Update_Button_Click

'Changes Due Dates
  Dim dStart As Date, dEnd as Date, iRowOn As Long
  dStart = cDate(Month(Now) & "/" & Day(Now) & "/" & Year(Now))
  dEnd = dStart + 90 'Dates count by number of days, so this sets dEnd 90 extra days out
  iRowOn = 2
  With ActiveSheet
    Do While .Cells(iRowOn, 1).Value & " " <> " " 'Processes until hits first blank cell in Column A
      If UCase(.Cells(iRowOn, 2).Value) = "CLOSED" Then
        .Cells(iRowOn, 3).Value = "Done"
      ElseIf .Cells(iRowOn, 1).Value >= dStart And .Cells(iRowOn, 1).Value <= dEnd Then
        .Cells(iRowOn, 3).Value = "Due Soon"
      ElseIf .Cells(iRowOn, 1).Value > dEnd Then
        .Cells(iRowOn, 3).Value = "Over Due"
        .Cells(iRowOn, 3).Value = "Not Due Yet"
      End If
      iRowOn = iRowOn + 1
  End With

End Sub

All times are GMT -4. The time now is 09:10 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.