Need urgent help in excel please

danish6061

New Member
Joined
Mar 16, 2020
Messages
29
Office Version
2016
Platform
Windows
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...
 

Some videos you may like

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.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
5,260
Office Version
365
Platform
Windows
Which cell will contain this formula ?
=A18
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
5,260
Office Version
365
Platform
Windows
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 :unsure:
- you cannot monitor the value in A18 AND use that cell for max\min value
 

danish6061

New Member
Joined
Mar 16, 2020
Messages
29
Office Version
2016
Platform
Windows
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
Joined
Mar 11, 2015
Messages
5,260
Office Version
365
Platform
Windows
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
Joined
Mar 16, 2020
Messages
29
Office Version
2016
Platform
Windows
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
Joined
Mar 11, 2015
Messages
5,260
Office Version
365
Platform
Windows
I will post amended code when back at my PC tomorrow
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
5,260
Office Version
365
Platform
Windows
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
Joined
Mar 16, 2020
Messages
29
Office Version
2016
Platform
Windows
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.
 

Forum statistics

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

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top