View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
David G[_5_] David G[_5_] is offline
external usenet poster
 
Posts: 4
Default Entering two functions in code

Hi,

My problem is entering some code which contains an IF statement and a
vlookup function into 1 line of code. I haven't programmed in Excel for a
while and I think I'm a little rusty. I am getting caught out with a syntax
error and I can't see what it is.

I'm dealing with a range of data which basically consists of 5 columns and a
variable number of rows. I will include the exact code below. What the code
is trying to do is put a formula in column 3 which, if isn't equal to zero,
takes the value in column 2 (same row) and goes to a lookup table elsewhere
on the sheet looks up the corresponding value in the lookup table and returns
that value to column 3. I need to do this by using formulas as listed below,
(Any help would be welcome). The line I'm showing below is a literal
representation. This formula needs to go into rng.Cells(2,3)
=if(D5 = 0, "SCR", VLookup(d5, $K$5:$M$40, 3, False)
I need to enter a generalised form of the above specific formula, but I keep
getting mixed up using constructs like ="=IF(Cells(2,3), "SCR",
vlookup(Cells(2,3), ......
I'm just not doing it right. If you can make sense of my message then
you'll probably be able to help me.
Thanks in advance
--
Regards
David G
Albury, Australia