Loop search, and calculate with multiple conditions

christchaaya

Board Regular
Joined
Apr 5, 2013
Messages
86
Hello everyone. I'm pretty new to VBA even if I already know how to do basic codes. In this case I have the idea but i don't know how to write it down. I'm working on a worksheet with 12k rows actives, and it's all structured as the table i posted below. What i have to do is substract the initial value (green one) to the final value (red one) and divide it to 1.18 ( if column a is 2012 and the value in b is <= 9) or 1.21 ( if column a is 2013 or it's 2012 and the value in b is >9). Then i have to substract to the result the values in column d that have in column c "aa".

The positive thing is that the dividing line is always 2 rows above the initial value and 1 row below the final value so i thought i can make a loop that search in column a for the value "*******" and then with offset make x= initial value , y = final value and make the operations i told before.:confused: ANY IDEA OF HOW I COULD WRITE THIS OR ALSO ALTERNATIVES WAY TO GET THE SAME RESULT ??? HELP IN ADVANCE :biggrin:
A
B
C
D
E
1
*******
===
===
===
===
2
3
0005PR
100
200
4
2012
02
bb
10
10
5
2012
04
bb
20
30
6
2012
10
aa
20
20
7
2012
11
bb
15
50
8
2012
11
aa
25
40
9
10
190
350
11
*******
===
===
===
===
12
13
0009PR
150
320
14
2012
02
bb
25
35
15
2012
05
bb
10
20
16
2012
05
bb
10
10
17
2012
10
bb
15
30
18
2013
01
aa
30
10
19
20
240
425
21
*******
===
===
===
===

<tbody>
</tbody>
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,196,480
Messages
6,015,448
Members
441,895
Latest member
Zululander

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top