Re: VBA Code Translation

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Melanie Breden (Melanie.BredenNOSPAM_at_mvps.org)
Date: 03/17/04


Date: Wed, 17 Mar 2004 17:21:42 +0100

Hi Q,

Q wrote:
> hi.
> how can i say the following in VBA Code:
> If A1 = B1 then use the phrase "Limitation of Costs" in
> cell C15 else (if they're not equal) use the
> phrase "Limitation of Funds" in cell C15. thanks very
> much in advance.

this Syntax is a little bit shorter:
Range("C15").Value = "Limitation of " & _
   IIf(Range("A1").Value = Range("B1").Value, "Costs", "Funds")

-- 
Regards
Melanie Breden
- Microsoft  MVP für Excel -
http://excel.codebooks.de (Das Excel-VBA Codebook)


Relevant Pages

  • Re: Message Box Help
    ... You should be using the IsNull function in VBA code: ... Second, though, your syntax is incorrect for the MsgBox statement. ...
    (microsoft.public.access.modulesdaovba)
  • RE: VBA code to count rows
    ... But I can write VBA code, ... pleae click yes if it was helpfull ... The challange is the names in Column A and Coulmn B are always variable- no ... Can someone please advise syntax of the code ...
    (microsoft.public.excel.worksheet.functions)
  • Re: vba doesnt trap errors?
    ... >so then in the vba code i tried ... >so it seems the bad syntax of using 'or' in the case statement just caused ... >faulty program execution instead of trapping an error???? ... >if this is so, is there some way to turn on error trapping, or test to find ...
    (microsoft.public.excel.programming)
  • Re: Stop Insert Row modifying formula data
    ... I ended up only needing the syntax to anchor the "top" reference in ... this instance because I can change the range with my VBA code. ...
    (microsoft.public.excel.misc)
  • Re: Incorrect syntax error
    ... I'll try that just to check the syntax. ... > "Roger Denison" wrote in message ... >> I have the following code in my VBA app: ... when I run the VBA code I get the following error: ...
    (microsoft.public.vb.database)