Copy Cell E value every n rows in A if (X-Y)<0 or (X-Z)<0

Seb1991

New Member
Joined
Apr 22, 2023
Messages
20
Office Version
  1. 365
Platform
  1. Windows
Hi guys, hope you're all fine. I need some help with the following macro
I'd like to copy a value of E2 in column A of the same row (A2) , if (L7-L22<0) or (L7-L33<0), in loop, so E2 in A2, from E2 every 45 rows so E47 in E47, E92 in A92 etc..
This macro should work as long as there is a value in E column (E2, E47, E92....)
I tried several times before asking here but i failed

Can you help me out with this ? Thank you so much for your time and your help!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
it doesn't say or i don't know where to see, it just pops up a window saying that, not underlining rows or part of the code
OK. When that box pops up, select Debug & one line will be highlighted in yellow. Which line?
 
Upvote 0
It doesnt say, or maybe it's me i don't see it, but when the window pops up it just says the error, if i press on ? it says error 9, but i can't see underlined rows or codes
 
Upvote 0
OK. I'm afraid there's nothing more I can do unless I can get a copy of the actual sheet you're using. Options are:
A) post a copy of your actual sheet using the XL2BB - Excel Range to BBCode, (preferred) or
B) share a copy of your file via Dropbox, Google Drive or any similar file sharing site (you can easily disguise any sensitive information if needed)
Otherwise - I'm working blind 😎
 
Upvote 0
You could always go down the formula path...

Book1
ABCDEFGHIJKL
1HDR1HDR2HDR3HDR4HDR5HDR6HDR7HDR8HDR9HDR10HDR11HDR12
2Product Row 1Product Row 1
3 Product Row 2
4 Product Row 3
5 Product Row 4
6 Product Row 5
7 Product Row 61
8 Product Row 7
9 Product Row 8
10 Product Row 9
11 Product Row 10
12 
13 
14 
15 
16 
17 
18 
19 
20 
21Product Row 20Product Row 20
22 Product Row 212
23 Product Row 22
24 Product Row 23
25 Product Row 24
26 Product Row 25
27 Product Row 26
28 Product Row 27
29 Product Row 28
30 Product Row 29
31 Product Row 30
32Product Row 31Product Row 31
33 Product Row 322
34 Product Row 33
35 Product Row 34
36Product Row 35Product Row 35
37 Product Row 36
38 Product Row 37
39 Product Row 38
40 Product Row 39
41 Product Row 40
42 Product Row 41
43 Product Row 42
44 Product Row 43
45 Product Row 44
46 Product Row 45
47Product Row 46Product Row 46
48 Product Row 47
49 Product Row 48
50 Product Row 49
51 Product Row 50
52 Product Row 511
53 Product Row 52
54 Product Row 53
55 Product Row 54
56 Product Row 55
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 2
68 
69 
70 
71 
72 
73 
74 
75 Product Row 74
76 Product Row 75
77Product Row 76Product Row 76
78 Product Row 772
79 Product Row 78
80 Product Row 79
81Product Row 80Product Row 80
82 Product Row 81
83 Product Row 82
84 Product Row 83
85 Product Row 84
86 Product Row 85
87 Product Row 86
88 Product Row 87
89 Product Row 88
90 Product Row 89
91 Product Row 90
92Product Row 91Product Row 91
93 Product Row 92
94 Product Row 93
95 Product Row 94
96 Product Row 95
971
98
99
100
101
102
103
104
105
106
107
108
109
110
111
1122
113
114
115
116
117
118
119
120
121
122
1232
Sheet2
Cell Formulas
RangeFormula
A2:A96A2=IF(E2<>"",IF(OR(L7-L22<0,L7-L33<0),E2,""),"")
 
Upvote 0
Here it is a piece of the file without the names (i think im not supposed to share this but anyway)

 
Upvote 0
Hi, Would you mind to post your expected result for one example of E2?
 
Upvote 0
Thank you for that. I suspect you didn't
Change the worksheet name to whatever you call it.
as advised in post #8. When I changed the sheet name to "Foglio1" - the code ran as I expected. I've shared the result on Google Drive - see if it's giving the expected result.
seb1991.xlsm
 
Upvote 0
Thank you for that. I suspect you didn't

as advised in post #8. When I changed the sheet name to "Foglio1" - the code ran as I expected. I've shared the result on Google Drive - see if it's giving the expected result.
seb1991.xlsm
I did change at first but it kept popping up the same error, so i guessed it was in english. But the result is different, a lot of values i don't need get copied in column A, i only need the value in column E2, E47, E92 etc, which is the product code.
In this case, E2 should not be copied because E7 (272) - E22 (0 because is empty) is >0 , i need to copy E7 in A7 only when is <0 , same as E7-E33 .
 
Upvote 0

Forum statistics

Threads
1,215,325
Messages
6,124,254
Members
449,149
Latest member
mwdbActuary

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