MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds


  Asked By: Clifford    Date: Jan 11    Category: MS Office    Views: 356

, i am working on a form in Excel (am just beginning VBA)

I have created about 4 or 5 forms and depending on which option is
answered determines which is the next form to open, this all works
fine but the last form i am creating, i only want to appear if the
quantities put in the previous form options exceeds a certain
value. when i type in the code simplified i can get it to work but
when i put it completely it doesnt

eg i want form 8 to open if the sum of cells B6 + B7 + B10 + B14 is
greater than 3.

this code i put in seems to work

if range ("B10").VALUE = 3 Then

but if i then extend this and put in
if range ("B6+B7+B10+B14).value => 3 then

this errors and being new to this i really dont know where i'm going
wrong and do i need more coding,



3 Answers Found

Answer #1    Answered By: Lurline Fischer     Answered On: Jan 11

Have you tried assigning B6+B7 etc to a variable and then using the variable to
check whether to show final form?

If you are unsure about using variables let me know and I'll try to explain.

Answer #2    Answered By: Alfonsine Miller     Answered On: Jan 11

You can't reference a sum  the way you're trying to, but there are a few
ways you could do this.

The easiest, I suppose, would be to put  a formula in a new cell to sum
the others and simply reference the value of this in you code. But if
you can't or don'twant to do that, then this is probably the simplest
way of doing the sum inside your code:

If Range("B6").Value + Range("B7").Value + Range("B10").Value +
Range("B14").Value => 3 then

Answer #3    Answered By: Fedde Bakker     Answered On: Jan 11

I was surprised when I found that

Range("B6").Value + Range("B7").Value + Range("B10").Value +
Range("B14").Value => 3

results in True if the cells  contain strings.

if application.WorksheetFunction.Sum(Range("B6,B10,B14")) >= 3
might work  better?

Didn't find what you were looking for? Find more on forms Or get search suggestion and latest updates.