VBA Code Translation

  • Thread starter Thread starter Q
  • Start date Start date
Q

Q

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.
~q
 
if Worksheets("YourSheet").Cells( 1,1).value = _
Worksheets("YourSheet").Cells(1,2).Value Then
Worksheets("YourSheet").Cells(1,3).Value = "Limitation of
costs"
else
Worksheets("YourSheet").Cells(1,3).Value = "Limitation of
Funds"
end if
 
Hi Q,
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)
 
Q said:
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.

If Range("A1").Value = Range("B1").Value Then
Range("C15").Value = "Limitation of Costs"
Else
Range("C15").Value = "Limitation of Funds"
End If

..Value can be discarded, as is the default property of a Range Object,
but is better to use for a better understanding of the code, besides it
helps to prevent errors.

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top