LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Modify existing code to dynamic code

Hello,

I have the following code to retrieve the next upcoming action. The
code works fine and does exactly what I want. However, I have lots of
projects listed in columns and want this formula to be listed under
each project.

The sheet looks like this:

columnA columnB columnC Column
D Column E
Project
A Project B
Phase 1 30-08-2007 Pending
1-10-2007 Pending
Phase 2 04-09-2007 Open
1-08-2007 Draft
Phase 3 01-01-2007 Finished
1-12-2007 Open
Phase X 13-10-2007 Cancelled
13-12-2007 Open

------ function Phase 1, Pending, 0
days Phase2, Draft, -29 Days



Function EarliestAction(ParamArray actions() As Variant) As String

LastRow = Cells(Rows.Count, "B").End(xlUp).Row

First = True
EarlistRow = 0
Found = False
For RowCount = 1 To LastRow
For action = 0 To UBound(actions())
If Cells(RowCount, "C") = actions(action) Then
If First = True Then
EarlistRow = RowCount
Found = True
First = False
Exit For
Else
If Cells(RowCount, "B") < _
Cells(EarlistRow, "B") Then

EarlistRow = RowCount
Exit For
End If
End If

End If
Next action
Next RowCount
If Found = True Then
If Cells(EarlistRow, "B") Now() Then
days = Int(Cells(EarlistRow, "B") - Now())
Else
days = Int(Now() - Cells(EarlistRow, "B"))
End If
EarliestAction = Cells(EarlistRow, "A") & _
", " & Cells(EarlistRow, "C") & ", " & _
days
If days = 1 Then
EarliestAction = EarliestAction & " day"
Else
EarliestAction = EarliestAction & " days"
End If

Else
EarliestAction = ""
End If

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to Modify Existing Code Ryan Hess Excel Programming 3 August 3rd 07 07:42 PM
almost there ... code modify help Ray Excel Programming 1 March 29th 07 12:58 PM
Can I use code/macro to change code/macro in an existing file? Scott Bedows Excel Programming 2 February 14th 07 05:50 AM
How to modify VBA code for Add-in? Shetty Excel Programming 1 March 3rd 04 04:04 PM
Help modify simple existing code?? ali Excel Programming 7 December 30th 03 11:03 PM


All times are GMT +1. The time now is 06:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"