hsandeep
Well-known Member
- Joined
- Dec 6, 2008
- Messages
- 1,226
- Office Version
- 2010
- Platform
- Windows
- Mobile
Range C2:C17 updates using formula & changes its value very fast.
In F2:F17 the highest value occurred in the cells C2:C17 is filled in ‘RESPECTIVE/CORRESPONDING’ cells of F2:F17 when A1=1 else ‘nothing is filled’.
In G2:G17 the lowest value occurred in the cells C2:C17 is filled in ‘RESPECTIVE/CORRESPONDING’ cells of G2:G17 when A1=1 else ‘nothing is filled’.
For this I am using the below code successfully till large extent (although it is slow in execution)
I want a new code to ADD the below action.
Range M2:M17 updates using formula & changes its value very fast. (in the same worksheet)
In P2:P17 the highest value occurred in the cells M2:M17 SHOULD BE FILLED in ‘RESPECTIVE/CORRESPONDING’ cells of P2:P17 when K1=1 else ‘nothing should be filled’.
In Q2:Q17 the lowest value occurred in the cells M2:M17 SHOULD BE FILLED in ‘RESPECTIVE/CORRESPONDING’ cells of Q2:Q17 when K1=1 else ‘nothing should be filled’.
Thanks in advance.
In F2:F17 the highest value occurred in the cells C2:C17 is filled in ‘RESPECTIVE/CORRESPONDING’ cells of F2:F17 when A1=1 else ‘nothing is filled’.
In G2:G17 the lowest value occurred in the cells C2:C17 is filled in ‘RESPECTIVE/CORRESPONDING’ cells of G2:G17 when A1=1 else ‘nothing is filled’.
For this I am using the below code successfully till large extent (although it is slow in execution)
Rich (BB code):
Private Sub Worksheet_Calculate()
'Code for Sheet H51
'Code checks/updates HIGHEST value occurred in C2:C16 & fills in F2:F16; C17 & fills in F17 when A1=1
'Code checks/updates LOWEST value occurred in C2:C3 & fills in G2:G16; C17 & fills in G17 when A1=1
Dim cell As Range
'Exit if A1 is not equal to 1
If Range("A1") <> 1 Then Exit Sub
'Loop through range of values that is being updated in C2:C16 & C17
For Each cell In Range("C2:C17")
'Check/update Maximum HIGHEST Value occurred in C2:C16 and FILL it in F2:F16; C17 in F17
If (Len(cell.Offset(0, 3)) > 0) And (IsNumeric(cell.Offset(0, 3))) Then
If cell > cell.Offset(0, 3) Then cell.Offset(0, 3) = cell
Else
cell.Offset(0, 3) = cell
End If
'Check/update Minimum LOWEST Value occurred in C2:C16 and FILL it in G2:G16; C17 in G17
If (Len(cell.Offset(0, 4)) > 0) And (IsNumeric(cell.Offset(0, 4))) Then
If cell < cell.Offset(0, 4) Then cell.Offset(0, 4) = cell
Else
cell.Offset(0, 4) = cell
End If
Next cell
End Sub
Book2.xlsx | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | 0 | Value | Value HIGHEST | Value LOWEST | |||||
2 | 1140.10 | ||||||||
3 | 1042.15 | ||||||||
4 | 942.35 | ||||||||
5 | 850.00 | ||||||||
6 | 759.95 | ||||||||
7 | 665.55 | ||||||||
8 | 579.45 | ||||||||
9 | 498.25 | ||||||||
10 | 422.00 | ||||||||
11 | 348.00 | ||||||||
12 | 283.85 | ||||||||
13 | 227.00 | ||||||||
14 | 177.95 | ||||||||
15 | 133.60 | ||||||||
16 | 100.65 | ||||||||
17 | 43233.90 | ||||||||
H51 |
I want a new code to ADD the below action.
Range M2:M17 updates using formula & changes its value very fast. (in the same worksheet)
In P2:P17 the highest value occurred in the cells M2:M17 SHOULD BE FILLED in ‘RESPECTIVE/CORRESPONDING’ cells of P2:P17 when K1=1 else ‘nothing should be filled’.
In Q2:Q17 the lowest value occurred in the cells M2:M17 SHOULD BE FILLED in ‘RESPECTIVE/CORRESPONDING’ cells of Q2:Q17 when K1=1 else ‘nothing should be filled’.
Book2.xlsx | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | |||
1 | 0 | Value | Value HIGHEST | Value LOWEST | 0 | Value | Value HIGHEST | Value LOWEST | |||||||||||
2 | 1140.10 | 1140.10 | |||||||||||||||||
3 | 1042.15 | 1042.15 | |||||||||||||||||
4 | 942.35 | 942.35 | |||||||||||||||||
5 | 850.00 | 850.00 | |||||||||||||||||
6 | 759.95 | 759.95 | |||||||||||||||||
7 | 665.55 | 665.55 | |||||||||||||||||
8 | 579.45 | 579.45 | |||||||||||||||||
9 | 498.25 | 498.25 | |||||||||||||||||
10 | 422.00 | 422.00 | |||||||||||||||||
11 | 348.00 | 348.00 | |||||||||||||||||
12 | 283.85 | 283.85 | |||||||||||||||||
13 | 227.00 | 227.00 | |||||||||||||||||
14 | 177.95 | 177.95 | |||||||||||||||||
15 | 133.60 | 133.60 | |||||||||||||||||
16 | 100.65 | 100.65 | |||||||||||||||||
17 | 43233.90 | 43233.90 | |||||||||||||||||
H51 |
Thanks in advance.