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: 28
Default There must be an eaiser way

I am creating a financial projection model which includes creation of a projected income statement where the user chooses from 5 different assumption "drivers" for each line item. I attempted to write a single line of code that would apply an IF-THEN statement to each line but ended up having to write a line of code for each line item (Revenue, COGS, Op.Exp, etc) for each year, 250 lines of code!!! Here is what I tried to write

Sub Test_Click(
If Sheets("Sheet1").Range("A1:A50").Value = "Input" Then Sheets("Sheet2").Range("B1:B50").formula =
"=Sheets("Sheet1").Range("B1:B50"
End Su

What I was trying to accomplish is have the code look at each individual line item assumption and if it was "Input" place the contents of the corresponding cell in the projected year

Here is a sample of what I had to do to get to work. Really slows my program down

Sub FormulaTest_Click(
If Range("B2").Value = "Input" Then Sheets("Sheet3").Range("B3").Formula = "=IncStmtAssump!C2
If Range("B2").Value = "% of Revenue" Then Sheets("Sheet3").Range("B3").Formula = "=IncStmtAssump!C2*Sheet3!B3
If Range("B2").Value = "% Change from Previous Year" Then Sheets("Sheet3").Range("B3").Formula = "=(1+IncStmtAssump!C2)*Sheet1!H3
If Range("B3").Value = "Input" Then Sheets("Sheet3").Range("B4").Formula = "=IncStmtAssump!C3
If Range("B3").Value = "% of Revenue" Then Sheets("Sheet3").Range("B4").Formula = "=IncStmtAssump!C3*Sheet3!B3
If Range("B3").Value = "% Change from Previous Year" Then Sheets("Sheet3").Range("B4").Formula = "=(1+IncStmtAssump!C3)*Sheet1!H4

There must be a way to get the original code idea to work..Please advise.
 
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



All times are GMT +1. The time now is 05:29 PM.

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"