Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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
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 help w/ adding cells and dividing SUM by number of cells lnbegin Excel Worksheet Functions 4 September 26th 07 04:26 PM
Adding comment to cells not working with merged cells mcphc Excel Programming 2 August 29th 07 07:09 PM
Sum not adding cells. carrera Excel Discussion (Misc queries) 3 June 12th 07 10:27 PM
Adding Cells STEVEB Excel Programming 3 November 9th 05 04:06 PM
Adding colour to a range of cells based on one of the cells v... McKenna Excel Discussion (Misc queries) 4 March 11th 05 02:25 PM


All times are GMT +1. The time now is 03:25 PM.

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

About Us

"It's about Microsoft Excel"