R1C1 Formula and FIND function

dilshod_k

Board Regular
Joined
Feb 13, 2018
Messages
79
Hello everyone.

Given:

Columns P and Q

Column P contains random values (Number Format) interspaced with unknown number of empty cells

The aim is to write code which returns value into “Q” Cell and fulfils criteria as it follows below:

If P Cell value = Nothing then Q Cell value = Nothing

If P Cell value > 0 then Q Cell value = (Next P Cell value (down the column) if it is > 0 – Current P Cell value)/Current P Cell value



For Example:

“P2” = “””” “Q2” = “”””

“P3” = 50 “Q3” = (150 – 50)/50

“P4” = “””” “Q4” = “”””

“P5” = “””” “Q5” = “”””

“P6” = 150 “Q6” = (80 – 150)/80

“P7” = “””” “Q7” = “”””

“P8” = 80 “Q8” = “””” if the rest of the values of Column P = “”””



I tried to use Formula:

FormulaR1C1 = " = IF (AND ( RC [-1] = “””” ), """" , IF ( AND ( RC [-1] > 0 ),""Text message"",""""))"

But I did not know how to incorporate FIND function instead of “Text message”

Would be grateful for any suggestions.

Thanks in advance.

Dil
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Try posting a sample of proper data with simple formulas to show the results by using XL2BB (link below) and asking your question in plain english instead of psuedo code.

 
Upvote 0
Analyser.xlsm
PQ
1SMA ValuesSMA Crossover
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
2092.76
21 
22 
23 
24 
25 
26 
27 
28 
29 
3097.62
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65140.60
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92136.90
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115137.75
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150129.71
151 
152 
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166129.44
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183128.90
184 
185 
186 
187 
188 
189 
190 
191 
192 
193 
194 
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
226 
227 
228 
229 
230 
231 
232 
233 
234134.15
235 
236 
237135.73
238 
239 
240 
241 
242 
243 
244 
245 
246 
247 
248 
BXP
Cell Formulas
RangeFormula
P2:P248P2=IF(AND(I2>J2,I3<J3),I2,IF(AND(I2<J2,I3>J3),I2, ""))
 
Upvote 0
That's not a sample, that's a column of formulas. There is nothing to show how the FIND function that you want to add to the formula relates to the data.

A sample should include 20-30 rows of data, not 200. It should show the results that you want and an explanation of how you get those results from the data shown.
 
Upvote 0
Hello again,

Sorry for confusing explanation.
I could not figure out what kind of function or formula to use in Column Q.
To explain as an example I'll use ranges Q20, Q30, Q92.
The value in Q cells should be:
Q20 = (P30-P20)/P20
Q30 = (P65 - P30)/P30
Q92 = (P92 - P65)/P65 e.t.c

Q cells with adjacent empty P cells should remain empty.

Obviously that the last value in Column P will not have one of the numerators and will give an error.

Thanks again.
Dil
 
Upvote 0
That's not a sample, that's a column of formulas. There is nothing to show how the FIND function that you want to add to the formula relates to the data.

A sample should include 20-30 rows of data, not 200. It should show the results that you want and an explanation of how you get those results from the data shown.
Sorry, I did not know how to submit explanation along with table, that is why I'm sending them separately.
Thanks,
Dil.
 
Upvote 0
So to be sure that I'm following correctly, you need a formula that is effectively =(x-y)/y

Where y refers to the number in the same row as the formula and x refers to the next number found looking down the column?

To add an explanation with the table, you can type it before or after the table code, just be sure not to change the code itself. Most people find it easier to type the explanation first, tap enter twice to create an empty line, then paste the table code below the empty line.
 
Upvote 0
Not exactly.
If the formula is z = (x-y)/y
Z is the resulting value and it should be in column Q
Whereas both X and Y values are in the column P
The value which is Y in one calculation will become X in the next one.
For instance: P30 is an analogue of X in the formula Q20
and P30 is an analogue of Y in the formula Q30.
So the value which was X in one calculation becomes Y in the next one.
 
Upvote 0
I think that's the same as what I said, just phrased differently. Try applying this to a range in column Q and see what happens.

I've assumed that there will always be less then 100 empty rows between numbers in column P, you can increase this if needed by increasing the number inside the square brackets R[100]. this needs to be done in 2 places, you can't use full columns and making the number too high will likely cause problems, the other square brackets R[1] should not be changed.

VBA Code:
FormulaArray = "=IFERROR(IF(RC16="""","""",(INDEX(R[1]C16:R[100]C16,MATCH(TRUE,ISNUMBER(R[1]C16:R[100]C16),0))-RC16)/RC16),"""")"
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,298
Members
449,077
Latest member
Rkmenon

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