PC Review


Reply
Thread Tools Rate Thread

adding to cells

 
 
dstiefe
Guest
Posts: n/a
 
      25th Mar 2008
I have a financial model that i've put together that is a 5 year projection
by month

i need to add a "if x <0,0,1" type of function within the cells. is there
anyway through VBA that i can scroll through the cells rather than manually.

i am somewhat familiar with VBA...

i would think that i have to create a variable that captures the existing
formula...then put the function in front of the existing formula...and then
update the variable..

but i'm not sure how to do it.

thank you
 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      25th Mar 2008
Without an example, this is only a guess:

Sub formulariser()
For Each r In Selection
If r.HasFormula Then
v = r.Formula
v = Right(v, Len(v) - 1)
r.Formula = "=if(" & v & "<0,0,1)"
End If
Next
End Sub

So if a cell has a formula like:

=A1+B1
then the sub would change it into:

=IF(A1+B1<0,0,1)

Is this what you want??
--
Gary''s Student - gsnu200775


"dstiefe" wrote:

> I have a financial model that i've put together that is a 5 year projection
> by month
>
> i need to add a "if x <0,0,1" type of function within the cells. is there
> anyway through VBA that i can scroll through the cells rather than manually.
>
> i am somewhat familiar with VBA...
>
> i would think that i have to create a variable that captures the existing
> formula...then put the function in front of the existing formula...and then
> update the variable..
>
> but i'm not sure how to do it.
>
> thank you

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding 4 cells next to eachother and then adding the following fourcells nadia.younus@googlemail.com Microsoft Excel Programming 3 29th May 2008 09:00 AM
Adding up range of cells exclude hide cells Len Microsoft Excel Programming 7 26th May 2008 02:36 PM
Adding comment to cells not working with merged cells =?Utf-8?B?bWNwaGM=?= Microsoft Excel Programming 2 29th Aug 2007 07:09 PM
Adding colour to a range of cells based on one of the cells v... =?Utf-8?B?TWNLZW5uYQ==?= Microsoft Excel Misc 4 11th Mar 2005 02:25 PM
adding/deleting cells in a named range of cells Tat Microsoft Excel Worksheet Functions 2 18th Nov 2003 03:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:29 AM.