Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Help Please: Need code to test several lines

This is a similar post to one yesterday but with the new infor. someone might be able to help

I am creating a financial projection model and need a single line of code that will run a formula based on an assumption "driver" unique to each line item in the financial statement. For instance, if C2 is "Input" then do "x" if C2 is "% of Revenue" do "y" etc and this test must run for each line in the financial statement

Here is what I have written but i get a "type mismatch" error and the same # is returned for each line item.. Please help

Sub ProjCal(
If Sheets("IncStmtAssump").Range("C2:C50").Value = "Input" Then Sheets("Sheet3").Range("B3:B50").Formula = "='IncStmtAssump'!D2
If Sheets("IncStmtAssump").Range("C2:C50").Value = "% of Revenue" Then Sheets("Sheet3").Range("B3:B50").Formula = "='IncStmtAssump'!D2*'Sheet3'!D2
End Su

In advance Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help Please: Need code to test several lines

Here is your problem

If Sheets("IncStmtAssump").Range("C2:C50").Value = "Input"

will give a type mismatch error since you are comparing an array to a
string.

You need to check one cell at a time.

--
Regards,
Tom Ogilvy

"bruce forster" wrote in message
...
This is a similar post to one yesterday but with the new infor. someone

might be able to help.

I am creating a financial projection model and need a single line of code

that will run a formula based on an assumption "driver" unique to each line
item in the financial statement. For instance, if C2 is "Input" then do "x"
if C2 is "% of Revenue" do "y" etc and this test must run for each line in
the financial statement.

Here is what I have written but i get a "type mismatch" error and the same

# is returned for each line item.. Please help.

Sub ProjCal()
If Sheets("IncStmtAssump").Range("C2:C50").Value = "Input" Then

Sheets("Sheet3").Range("B3:B50").Formula = "='IncStmtAssump'!D2"
If Sheets("IncStmtAssump").Range("C2:C50").Value = "% of Revenue"

Then Sheets("Sheet3").Range("B3:B50").Formula =
"='IncStmtAssump'!D2*'Sheet3'!D2"
End Sub

In advance Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Help Please: Need code to test several lines

Can you suggest some code for a loop.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help Please: Need code to test several lines

Something like:

for each cell in Sheets("IncStmtAssump").Range("C2:C50")
if cell.Value = "Input" then
Worksheets("Sheet3").Range( _
cell.offset(0,1).Address).Formula = _
"='IncStmtAssump'!D" & cell.row
End if
Next

--
Regards,
Tom Ogilvy

"bruce forster" wrote in message
...
Can you suggest some code for a loop.



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
Event (BeforeSave) - How to test VBA code? Dave P. can you hear me now? EagleOne Excel Discussion (Misc queries) 3 September 14th 06 07:46 PM
Limit on Number of Lines of VBA Code? Mark D'Agosta Excel Programming 1 November 11th 03 11:22 PM
Lines fo code Neeraja[_2_] Excel Programming 2 October 16th 03 01:07 PM
help reducing lines of code Robert Christie Excel Programming 3 September 14th 03 02:12 PM
Code Text Into Chart Lines? Phil Hageman Excel Programming 3 July 17th 03 11:51 AM


All times are GMT +1. The time now is 10:50 AM.

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"