Copy a cell value based on condition
Solved
McFly
-
Mike-31 Posted messages 18405 Registration date Status Contributeur Last intervention -
Mike-31 Posted messages 18405 Registration date Status Contributeur Last intervention -
Hello,
I'm reaching out to you because I'm stuck on creating a macro.
I have a table with the following columns:
- the number of employees in the company
- workforce categories
- contract amounts
I want to test the amount in each cell for each workforce category, and based on its value, there are two solutions:
- if its value does not exceed a value x, we copy this value into a fourth column
- if its value exceeds value x, we write value x in the fourth column
Unfortunately, I don’t know how to do this. I spent the morning on it and I'm lost. My macros do nothing or crash... I’m starting to get frustrated, I must admit.
Could you help me?
Thank you very much,
McFly
I'm reaching out to you because I'm stuck on creating a macro.
I have a table with the following columns:
- the number of employees in the company
- workforce categories
- contract amounts
I want to test the amount in each cell for each workforce category, and based on its value, there are two solutions:
- if its value does not exceed a value x, we copy this value into a fourth column
- if its value exceeds value x, we write value x in the fourth column
Unfortunately, I don’t know how to do this. I spent the morning on it and I'm lost. My macros do nothing or crash... I’m starting to get frustrated, I must admit.
Could you help me?
Thank you very much,
McFly
Configuration: Windows 7 Firefox 3.0.17
10 réponses
Well, actually, it's more complicated.
Let's say I have 6 classes of sizes: [0-9], [10-29], [30-49], [50-99], [100-199], and [200-250]
For each class size, I have a maximum amount not to exceed.
[0-9] ==> 14840
[10-29] ==> 29191
[30-49] ==> 40000
[50-99] ==> 47406
[100-199] ==> 50279
[200-250] ==> 76185
I have a base of about 550 rows. I need to test the cell where I have my class sizes, once that's done, I test the amount, and based on the class size, I check if this amount exceeds my ceiling. Then, I either keep the initial amount or replace it with my ceiling.
With an IF formula, I don’t see how to do it. It would be too complex, right?
That's why I turned to VBA actually, even if my level limits me at this time :D.
Let's say I have 6 classes of sizes: [0-9], [10-29], [30-49], [50-99], [100-199], and [200-250]
For each class size, I have a maximum amount not to exceed.
[0-9] ==> 14840
[10-29] ==> 29191
[30-49] ==> 40000
[50-99] ==> 47406
[100-199] ==> 50279
[200-250] ==> 76185
I have a base of about 550 rows. I need to test the cell where I have my class sizes, once that's done, I test the amount, and based on the class size, I check if this amount exceeds my ceiling. Then, I either keep the initial amount or replace it with my ceiling.
With an IF formula, I don’t see how to do it. It would be too complex, right?
That's why I turned to VBA actually, even if my level limits me at this time :D.