PDA

View Full Version : Excel macro help



D_o_S
06-04-2009, 02:02 AM
Hi all,

I need some help with an excel macro...

I have a spreadsheet in which there are several items, each item having a code.

For example:
Code Name Cost
55020 Home assistance 521
55999 Car ride 777
69100 Workshop 911

Etc....

There is a formula for each of the values after the Name.

I need two things: whenever an item with a 6xxxxxx code comes up, I need the cost formula to be multiplied by -1.

I also have some categories, i.e.

Codes 50000 to 51000 are N1, 51000 to 55000 are N2, etc....

I need some sort of macro/program that will take each value in column A (which is the code), determine which category it is, then transfer to the C cell with the corresponding cost, and add that value to the total category cost...

Anyone?

Qkjhfhaiguihfma
06-21-2009, 08:59 AM
no need for a macro (sounds like). just use some nested IF's and the function wizard to find the right text functions. you can easily identify the first N characters of a string using a basic function.

Easybeat
06-23-2009, 03:37 AM
Quick and dirty as I am at work and only works for a single cell

Cell A1 contents
Value to be checked

Cell A2 contents
=IF(A1>59999,IF(A1<70000,-1,0),0)

You either link a lot of if statements together which will be tedious or use a Lookup command. Lookup compares the value against a table and then returns another value stored in the table. Harder describe than it is to use.