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: 161
Default Two problems inserting a formula

Hi,

I have a piece of code that inserts a formula into a specific cell on a
line. The formula looks at five possible values on the same line, calculates
the average of the highest three of them and then uses this output (along
with another value) to look up a new value from a table (this is what the
offset does).

I am happy that the formula works as intended - when I enter it manually
into the sheet it works. What I can't work out is how to assign the formula
to the necessary cell - I keep getting an error when I use the code below:

sFormula = "=IF(ISERROR(OFFSET('User Data'!$D$13,-C" & lLineCount &
",ROUND((LARGE(D" & lLineCount & ":H" & lLineCount & ",1)+LARGE(D" &
lLineCount & ":H" & lLineCount & ",2)+LARGE(D" & lLineCount & ":H" &
lLineCount & ",3))/3,0)))," & Chr(34) & ",OFFSET('User Data'!$D$13,-C" &
lLineCount & ",ROUND((LARGE(D" & lLineCount & ":H" & lLineCount &
",1)+LARGE(D" & lLineCount & ":H" & lLineCount & ",2)+LARGE(D" & lLineCount &
":H" & lLineCount & ",3))/3,0)))"
Range("I" & lLineCount).Value = sFormula

Two questions:
1) what is the correct syntax to get the Range... line working?
2) the formula feels really clunky, can anyone suggest anything that
simplifies it?

TIA

Dave
 
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
problems with inserting comments Derrick Excel Discussion (Misc queries) 1 August 19th 09 04:28 PM
Problems Inserting Objects in an Excel 2007 Spreadsheet [email protected] Excel Discussion (Misc queries) 0 May 18th 09 10:40 PM
Inserting VLookup using VBA - Problems concatinating contents of cell & variable [email protected] Excel Programming 5 April 20th 07 09:20 AM
Problems inserting rows KathleenK Excel Discussion (Misc queries) 1 August 18th 05 02:13 AM
Problems inserting pictures in Excel 2002 sp-2 L.Skaggs Excel Discussion (Misc queries) 11 August 18th 05 01:14 AM


All times are GMT +1. The time now is 10:40 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"