I have a coloumn (i.e. A) with hundreds of numbers. I'd like to be able to write a number in a cell (i.e. B4), and have Excel find and tell the coordinates of those cells in coloumn A that sum up to the result I wrote in B4 (i.e., 32). I also would like to be able to "hit a key" and see the next possible set of result-cells.
I first found usable code to sum in sequence - Ill call VBA1 which I used successfully to produce the running total in the adjacent column. I must now revise the code to identify the groups of cells in the running total column that do not exceed a value (i.e., value set is cell c170 which happens to be 32). So I want to identify
Columns A= Row#; Column B=Starting values; Column C= Running total & cell C170 =32,,, I want to find c15, then I want to find the next set which is c27, and so on,,, Find the coordinate of the cell where the sum of the preceding cells is equal to or less than 32 (not >32), then start over from the next cell, and so on until the end of the list.
A B C
1 1 1
2 2 3
3 1 4
4 4 8
5 1 9
6 3 12
7 1 13
8 3 16
9 1 17
10 4 21
11 1 22
12 4 26
13 1 27
14 3 30
15 1 31*
16 4 35
17 1 36
18 3 39
19 1 40
20 5 45
21 1 46
22 4 50
23 1 51
24 6 57
25 1 58
26 3 61
27 1 62*
28 3 65
29 1 66
30 3 69
31 1 70
32 4 74
33 1 75
34 5 80
35 1 81
36 4 85
37 1 86
38 4 90
39 1 91
40 4 95
41 1 96
42 2 98
43 1 99
44 4 103
45 1 104
46 4 108
47 1 109
48 5 114
49 1 115
50 5 120
51 1 121
52 2 123
53 1 124
54 2 126
55 1 127
56 5 132
57 1 133
58 4 137
59 1 138
60 3 141
61 1 142
62 4 146
63 1 147
64 3 150
65 1 151
66 3 154
67 1 155
68 4 159
69 1 160
70 3 163
71 1 164
72 3 167
73 1 168
74 3 171
75 1 172
76 3 175
77 1 176
78 2 178
79 1 179
80 3 182
81 1 183
82 3 186
83 1 187
84 7 194
85 1 195
86 3 198
87 1 199
88 4 203
89 1 204
90 3 207
91 1 208
92 3 211
93 1 212
94 3 215
95 1 216
96 3 219
97 1 220
98 4 224
99 1 225
100 4 229
101 1 230
102 4 234
103 1 235
104 2 237
105 1 238
106 5 243
107 1 244
108 4 248
109 1 249
110 4 253
111 1 254
112 2 256
113 1 257
114 4 261
115 1 262
116 2 264
117 1 265
118 4 269
119 1 270
120 3 273
121 1 274
122 4 278
123 1 279
124 4 283
125 1 284
126 4 288
127 1 289
128 4 293>
129 1 294
130 3 297
131 1 298
132 3 301
133 1 302
134 2 304
135 1 305
136 2 307
137 1 308
138 2 310
139 1 311
140 2 313
141 1 314
142 2 316
143 1 317
144 3 320
145 1 321
146 2 323
147 1 324
148 5 329
149 1 330
150 3 333
151 1 334
152 2 336
153 1 337
154 2 339
155 1 340
156 3 343
157 1 344
158 3 347
159 1 348
160 5 353
161 1 354
162 3 357
163 1 358
164 4 362
165 1 363
166 6 369
VBA1 =
Sub runbalance()
Dim wksht As Worksheet
Dim counter As Long
Set wksht = ThisWorkbook.ActiveSheet
For counter = 1 To 200
wksht.Cells(counter, 1).Offset(0, 1).Value = Application.WorksheetFunction.Sum(wksht.Range(Cells(1, 1), Cells(counter, 1)).Value)
Next counter
End Sub
I now need to do something with the code to achieve the goal.
Much appreciate any help!
I first found usable code to sum in sequence - Ill call VBA1 which I used successfully to produce the running total in the adjacent column. I must now revise the code to identify the groups of cells in the running total column that do not exceed a value (i.e., value set is cell c170 which happens to be 32). So I want to identify
Columns A= Row#; Column B=Starting values; Column C= Running total & cell C170 =32,,, I want to find c15, then I want to find the next set which is c27, and so on,,, Find the coordinate of the cell where the sum of the preceding cells is equal to or less than 32 (not >32), then start over from the next cell, and so on until the end of the list.
A B C
1 1 1
2 2 3
3 1 4
4 4 8
5 1 9
6 3 12
7 1 13
8 3 16
9 1 17
10 4 21
11 1 22
12 4 26
13 1 27
14 3 30
15 1 31*
16 4 35
17 1 36
18 3 39
19 1 40
20 5 45
21 1 46
22 4 50
23 1 51
24 6 57
25 1 58
26 3 61
27 1 62*
28 3 65
29 1 66
30 3 69
31 1 70
32 4 74
33 1 75
34 5 80
35 1 81
36 4 85
37 1 86
38 4 90
39 1 91
40 4 95
41 1 96
42 2 98
43 1 99
44 4 103
45 1 104
46 4 108
47 1 109
48 5 114
49 1 115
50 5 120
51 1 121
52 2 123
53 1 124
54 2 126
55 1 127
56 5 132
57 1 133
58 4 137
59 1 138
60 3 141
61 1 142
62 4 146
63 1 147
64 3 150
65 1 151
66 3 154
67 1 155
68 4 159
69 1 160
70 3 163
71 1 164
72 3 167
73 1 168
74 3 171
75 1 172
76 3 175
77 1 176
78 2 178
79 1 179
80 3 182
81 1 183
82 3 186
83 1 187
84 7 194
85 1 195
86 3 198
87 1 199
88 4 203
89 1 204
90 3 207
91 1 208
92 3 211
93 1 212
94 3 215
95 1 216
96 3 219
97 1 220
98 4 224
99 1 225
100 4 229
101 1 230
102 4 234
103 1 235
104 2 237
105 1 238
106 5 243
107 1 244
108 4 248
109 1 249
110 4 253
111 1 254
112 2 256
113 1 257
114 4 261
115 1 262
116 2 264
117 1 265
118 4 269
119 1 270
120 3 273
121 1 274
122 4 278
123 1 279
124 4 283
125 1 284
126 4 288
127 1 289
128 4 293>
129 1 294
130 3 297
131 1 298
132 3 301
133 1 302
134 2 304
135 1 305
136 2 307
137 1 308
138 2 310
139 1 311
140 2 313
141 1 314
142 2 316
143 1 317
144 3 320
145 1 321
146 2 323
147 1 324
148 5 329
149 1 330
150 3 333
151 1 334
152 2 336
153 1 337
154 2 339
155 1 340
156 3 343
157 1 344
158 3 347
159 1 348
160 5 353
161 1 354
162 3 357
163 1 358
164 4 362
165 1 363
166 6 369
VBA1 =
Sub runbalance()
Dim wksht As Worksheet
Dim counter As Long
Set wksht = ThisWorkbook.ActiveSheet
For counter = 1 To 200
wksht.Cells(counter, 1).Offset(0, 1).Value = Application.WorksheetFunction.Sum(wksht.Range(Cells(1, 1), Cells(counter, 1)).Value)
Next counter
End Sub
I now need to do something with the code to achieve the goal.
Much appreciate any help!