Find largest number in my range but not to include the active cell

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

Please can someone help?

If it is possible at all, I would like to edit this code so when it searches in the range for the largest number, it doesn't include the cell that has just been edited.

Code:
Sub ShowMax(Optional ByVal Target As Range)

    Dim TheMax As Double
    
    TheMax = WorksheetFunction.Max(Range("D6:BM20"))


End Sub

Any help would be much appreciated.

Regards

Dan
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Code:
Sub ShowMax(Optional ByVal Target As Range)

    Dim TheMax As Double
    
    TheMax = WorksheetFunction.Max(Range("D6:BM20"))
    If Target.Value = TheMax Then TheMax = Worksheetfunction.Large(Range("D6:BM20"), 2)

End Sub
 
Upvote 0
Hi mikerickson,

That's perfect. Thank you so much for your help.

Thanks

Dan
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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