Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
adding to cells
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
adding to cells
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need help w/ adding cells and dividing SUM by number of cells | Excel Worksheet Functions | |||
Adding comment to cells not working with merged cells | Excel Programming | |||
Sum not adding cells. | Excel Discussion (Misc queries) | |||
Adding Cells | Excel Programming | |||
Adding colour to a range of cells based on one of the cells v... | Excel Discussion (Misc queries) |