Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Vba Or Function ?

Status
Not open for further replies.

amal1973

Technical User
Jul 31, 2001
131
US
Hello ,
I would like to write an excel function or a VBA function in Excel, What it will do is:
If the amount in column N is more that zero, Go and look at column D and E and F by choosing the latest date from these three columns and then putting the difference in dates between that latest date and Now in Column B. Hope that is make sense
 
=if(N2>0,max(D2:F2)-NOW(),"")
format the cell as general

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Thanks a million , I did not think it would be so easy , problem solved , But if i wanted to have something like that in a vba function is it dowable ?
 
yep but why bother ???

as a function

function DaysDiff(rng as range)
if rng.value <= 0 then
DaysDiff = &quot;&quot;
exit function
end if
uRw = rng.row
DaysDiff = max(range(&quot;D&quot; & uRw & &quot;;F&quot; & uRw))-now()
end function

as a sub

Sub DaysDiff()
uRw = selection.row
if cells(uRw,14).value <=0 then
cells(uRw,2).value = &quot;&quot;
exit sub
end if
cells(uRw,2).value = max(range(&quot;D&quot; & uRw & &quot;;F&quot; & uRw))-now()
end sub

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Thats what i was looking for .. cant thank you enoght
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top