View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Stockwell43 Stockwell43 is offline
external usenet poster
 
Posts: 59
Default VBA Code Please help!!

Hi Andrew,

What you are saying does make sense to me. What I need to do is to say
something like:
If F15 = 230,231,331,336 Then G15 = 0.1000 else 0.0014

In the logical test, I do one value but not several. How do I do this so if
any of the above number are input into F15 G15 will show 0.1000 and if the
number in F15 is not one of the above G15 will show 0.0014?

Any help you can give me would most appreciated.

Thank you!!

"Andrew" wrote:

On May 9, 1:24 pm, Stockwell43
wrote:
Hello,

I am not very familar with Excel programming but here it goes. My manager
gave me a spreadsheet that need an If statement in a cell. It is actually in
each cell in the whole column. When I figure out what the statement should
be, where do I put it? How do I get to the screen where I put the code in?
Surely it can't be a macro can it? Any help would be most appreciated.

Thanks!!


Hi

This isn't really VBA. There is a VBA IF statement, but it looks like
you're needing a simple Worksheet Function (in other words one which
goes into a cell, rather than one is written as part of a VBA
routine).

That said, you need to select the cell in which you want to see the
answer appear, and simply type the function, with it's supporting
information (the "arguments"), preceded by an = sign, into that cell.

As an example, if A1 and B1 contained sales figures, and you wanted to
mark them as either HIGH or LOW in C1, depending on whether the total
sale was above 100, you would type the following into C1 (not
forgetting to press Enter at the end):
=IF(A1+B1100,"HIGH","LOW")

As you may be able to see from this, there are 3 parts to the IF
function, separated with commas.

The first part is the TEST - what you're looking to evaluate. In this
case, we simply said A1+B1100, but we could also have written
something like SUM(A1:B1)100 and the result would be the same.

The second part is what to do if the test is TRUE - in other words
A1+B1 IS greater than 100. In this case, we simply said "put the word
'HIGH' in the current cell (C1)" But we could just as easily have said
something like (A1+B1)*1.1 if we'd wanted to show the value of adding
10% to the total of A1+B1, or indeed any other such calculation. Just
remember that if you want to put a piece of text rather than a
calculation, that text must go in quotation marks.

The final part of the function is what to do if the test is FALSE. It
follows all the same rules and patterns as the TRUE part, as described
above.

The three parts - again, called the arguments, or the parameters - are
surrounded by parentheses.

You mention having to put the formula in every cell in a column. The
best way to do this is to get the formula to work in the first cell.
Once you're happy that it's giving you the answer you need, select
that cell with the answer (C1 in our example above) and then hover
with the mouse over the black dot in the bottom-right corner of the
cell. This is known as the AutoFill Handle. The mouse pointer will
change to a black cross. When you have this appearing, click and drag
down in the column for as far as you want the formula to be copied.

This should do the trick for you!

Andrew