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

CodePudding user response:

refer to the second floor zhao4zhong1 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,

Recording macros, is not everything, there are some things is "not down"!!!!!!

CodePudding user response:

This use conditional formatting can (can be set static/dynamic) :

 Option Explicit 
Sub test ()
"' test code
SetMaxAndMinHighLight Sheet1. Range (" b1: b18 ")
End Sub
Sub SetMaxAndMinHighLight (Rng As Excel. Range)
' ' ' 'this code you just need to perform a
On the Error Resume Next
With Rng. FormatConditions
. Delete
. Add the Type:=xlCellValue, Operator:=xlEqual, Formula1:="=MAX (" & amp; Rng. Address & amp;
")". Add the Type:=xlCellValue, Operator:=xlEqual, Formula1:="=MIN (" & amp; Rng. Address & amp;
")"End With
With Rng. FormatConditions (1)
. The Font. Bold=True ' ' ' ' ' ' ' ' ' 'Bold
, the Font Color=vbWhite ' ' ' ' ' 'white
. The Interior. The Color=vbRed '"' background Color - red
End With
With Rng. FormatConditions (2)
. The Font. Bold=True ' ' ' ' ' ' ' ' ' 'Bold
, the Font Color=vbWhite ' ' ' ' ' 'blue
. The Interior. The Color=vbBlue "' background Color - blue
End With
End Sub

'


If not sure can make it dynamic cell area...

CodePudding user response:

reference 4 floor Chen8013 response:
Quote: refer to the second floor zhao4zhong1 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,

Recording macros, is not everything, there are some things is "not down"!!!!!!

Not afraid not to record down, afraid yao can do manual, is not to do with VBA,
Specifically to an after flagrantly against Microsoft removed the function of recording macros,

CodePudding user response:

refer to 6th floor zhao4zhong1 response:
Quote: refer to 4th floor Chen8013 response:

Quote: refer to the second floor zhao4zhong1 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,

Recording macros, is not everything, there are some things is "not down"!!!!!!

Not afraid not to record down, afraid yao can do manual, is not to do with VBA,
Specifically to an after flagrantly against Microsoft removed the function of recording macros,

Who said after 2007 to remove the record macro? (it is no wonder that you also emphasized to use the 2003 version)
Your installation is "super gimped" Office?

At least, I installed 2007201 pro, this feature exists,
(I am not used later)

CodePudding user response:

refer to 7th floor Chen8013 response:
Quote: refer to the sixth floor zhao4zhong1 response:

Quote: refer to 4th floor Chen8013 response:

Quote: refer to the second floor zhao4zhong1 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,

Recording macros, is not everything, there are some things is "not down"!!!!!!

Not afraid not to record down, afraid yao can do manual, is not to do with VBA,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • VBA
  • Related