Need urgent help in excel please

danish6061

New Member
In simple words, I want a code which will work for cell a1 and a18 in same sheet and shows the result in Z2 and Z3 and A18 and A18...

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

danish6061

New Member
Sorry, shows the result in A18 and A19

Yongle

Well-known Member
Which cell will contain this formula ?
=A18

Yongle

Well-known Member
In simple words, I want a code which will work for cell a1 and a18 in same sheet and shows the result in Z2 and Z3 and A18 and A19...
(
above amended for this Sorry, shows the result in A18 and A19 )

This makes no sense
- you cannot monitor the value in A18 AND use that cell for max\min value

danish6061

New Member
Sorry to unclarify you, I just want this same thing in cell A18, because data will cautiously change in A18 too.

Yongle

Well-known Member
I am unable to help until you understand what I am telling you

You cannot use A18 for max and A19 for min if cell A18 is the cell being monitored

danish6061

New Member
Ohhhh.. my typing mistake,
I apologize you to bothering you.
Actually data will be monitored in A1 and A18 cells and result should be shown in Z1 and Z2 for A1 cell, and Z18 and Z19 for A 18 cell. *(In same sheet)

Yongle

Well-known Member
I will post amended code when back at my PC tomorrow

Yongle

Well-known Member
I used Z18 cell as trigger cell when value A18 changes
Enter this formula in Z18
=A18

I used Z19 and Z20 to hold MIN & MAX values for A18

VBA Code:
``````Private oldValueA1 As Variant, oldValueA18 As Variant

Private Sub Worksheet_Calculate()
If CStr(oldValueA1) = "" Then
Range("Z3") = 9999999
Range("Z2") = 0
End If
If CStr(oldValueA18) = "" Then
Range("Z20") = 9999999
Range("Z19") = 0
End If
If Range("A1") = oldValueA1 And Range("A18") = oldValueA18 Then Exit Sub
oldValueA1 = Range("A1").Value
oldValueA18 = Range("A18").Value
Call MacroY
End Sub

Sub MacroY()
'A1 values
Range("Z2") = WorksheetFunction.Max(Range("A1"),Range("Z2"))
If Range("Z3") = 0 Then Range("Z3") = 9999999
Range("Z3") = WorksheetFunction.Min(Range("A1"), range("Z3"))
'A18 values
Range("Z19") = WorksheetFunction.Max(Range("A18"),Range("Z19"))
If Range("Z20") = 0 Then Range("Z20") = 9999999
Range("Z20") = WorksheetFunction.Min(Range("A18"), range("Z20"))
End Sub``````
As you can see I have replicated everything for A1, Z1, Z2, Z3 and referred to A18, Z18, Z19, Z20
If you want to add any more monitored cells then amend the code yourself using the same technique

danish6061

New Member
But By this code the value of cell a1 and a18 will be the same but i will trigger different values in both cells thats why need different max. min, values for both cells.

1,089,529
Messages
5,408,810
Members
403,231
Latest member
FlorianPhil