Home > Software engineering > According to the user's choice of cell, highlighting the biggest, the minimum line
According to the user's choice of cell, highlighting the biggest, the minimum line
Time:09-23
VBA, excel, running, you first need the user to select a few cell (may be continuous or scattered, but all in the same column), the user is determined, highlighting the maximum and minimum value in the line, to find a lot of resources, the code still can't write, ask everybody to help, I interns, this is very important to me, thank you!
CodePudding user response:
Institute of technology of profession of VB6 visual programming (wuxi) http://download.csdn.net/detail/zhao4zhong1/6824713
CodePudding user response:
Start recording macros in Excel 2003, manual, complete the required function end record macros, press Alt + F11 key, check just record macro corresponding VBA code,
CodePudding user response:
Give you a piece of code reference, specific applications, his reference to modify:
Open the VBE varies, as a supplement to a standard module (or use the existing), paste the code below, Then, as you say "in a list of selected multiple cell (can be a" decentralized ") ", Then press "Alt + F8", select FindMaxMin process, execute it, see the effect,
Public Sub FindMaxMin () Dim objCMax As Range Dim objCMin As Range Dim i& , u As Long Dim As Double on3dmax Dim dMin As Double Dim dVal As Double
U=Selection. Cells. The Count If (u & lt; 2 & amp;) Then MsgBox "please select more than one cell after the execution!" , 48 The Exit Sub End the If The Set objCMax=Selection. Cells (1, 1) The Set objCMin=objCMax Value)=on3dmax Val (objCMax. DMin=on3dmax For I=2 & amp; To u DVal=Val (Selection) Cells (I, 1). The Value) If (dVal & gt; Then on3dmax) =on3dmax dVal The Set objCMax=Selection. Cells (I, 1) ElseIf (dVal & lt; DMin) Then DMin=dVal The Set objCMin=Selection. Cells (I, 1) End the If Next With ActiveSheet. Rows (objCMin. Row). Interior . The Pattern=xlSolid . PatternColorIndex=xlAutomatic Color=15773696 End With With ActiveSheet. Rows (objCMax. Row). Interior . The Pattern=xlSolid . PatternColorIndex=xlAutomatic Color=255 End With The Set objCMax=Nothing The Set objCMin=Nothing End Sub