怎么有错啊Sub GetMax()
Range.Find(Application.WorksheetFunction.Max(Range("D1:D24"))).Activate
ActiveSheet.Cells(1, 1).Interior.ColorIndex = 3
End Sub

解决方案 »

  1.   

    可以用条件格式,试试这个 
        Range("D1:D24").FormatConditions.Delete
        Range("D1:D24").FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=MAX($D$1:$D$24)"
        Range("D1:D24").FormatConditions(1).Font.ColorIndex = 3
        Range("D1:D24").FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="=MIN($D$1:$D$24)"
        Range("D1:D24").FormatConditions(2).Font.ColorIndex = 6
      

  2.   

    Range("D1:D24").FormatConditions.Delete
    Range("D1:D24").FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
    Formula1:="=MAX($D$1:$D$24)"
    Range("D1:D24").FormatConditions(1).Interior.ColorIndex = 3
    Range("D1:D24").FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
    Formula1:="=MIN($D$1:$D$24)"
    Range("D1:D24").FormatConditions(2).Interior.ColorIndex = 6不错呀!
      

  3.   

    剪切和插入
    Range("A4").Select '最大值单元'
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Cut
    Range("A1").Select
    Selection.Insert Shift:=xlDown
      

  4.   

    其实不用VBA找啊,你可以直接用条件格式实现。
      

  5.   

    你只需要选中A列,然后条件格式中选择公式,输入  =A1=max(A:A)
    然后把格式复制到其它所有需要的列就可以了。
      

  6.   

    看这个:
    Sub Main()
        Dim i&, strCh$
        For i = 1 To 150        '对第1列到150列加条件格式
            If (i < 27) Then
                strCh = Chr$(64 + i)
            Else
                strCh = Chr$(65 + (i - 1) \ 26) & Chr$(65 + (i - 1) Mod 26)
            End If
            strCh = strCh & "1:" & strCh & "24"
            Range(strCh).FormatConditions.Delete
            Range(strCh).FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=MAX($D$1:$D$24)"
            Range(strCh).FormatConditions(1).Font.ColorIndex = 3
            Range(strCh).FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=MIN($D$1:$D$24)"
            Range(strCh).FormatConditions(2).Font.ColorIndex = 6
        Next
    End Sub
      

  7.   

    不好意思,忘记了后面的公式,更正一下:
    Sub Main()
        Dim i&, strCh$, strRange$
        For i = 1 To 150        '对前150列加条件格式
            If (i < 27) Then
                strCh = Chr$(64 + i)
            Else
                strCh = Chr$(65 + (i - 1) \ 26) & Chr$(65 + (i - 1) Mod 26)
            End If
            strRange = strCh & "1:" & strCh & "24"
            Range(strRange).FormatConditions.Delete
            Range(strRange).FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=MAX($" & strCh & "$1:$" & strCh & "$24)"
            Range(strRange).FormatConditions(1).Font.ColorIndex = 3
            Range(strRange).FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=MIN($" & strCh & "$1:$" & strCh & "$24)"
            Range(strRange).FormatConditions(2).Font.ColorIndex = 6
        Next
    End Sub
      

  8.   

    可以用Excel自带的功能:菜单:
    格式-->条件格式在其中可进行详细设置,还是很不错嘀~~
      

  9.   

    http://topic.csdn.net/u/20100401/15/1688881b-8bd0-4320-aaa8-1ccfc4d8294f.html
      

  10.   

    哪位大侠帮忙解释一下啊,。诶看明白Sub Main()
        Dim i&, strCh$, strRange$
        For i = 1 To 150        '对前150列加条件格式
            If (i < 27) Then ‘这个27是干嘛用的
                strCh = Chr$(64 + i)’还有这个64
            Else
                strCh = Chr$(65 + (i - 1) \ 26) & Chr$(65 + (i - 1) Mod 26)‘26一样不明白
            End If
            strRange = strCh & "1:" & strCh & "24"’strRange用来做什么?
            Range(strRange).FormatConditions.Delete
            Range(strRange).FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=MAX($" & strCh & "$1:$" & strCh & "$24)"
            Range(strRange).FormatConditions(1).Font.ColorIndex = 3
            Range(strRange).FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=MIN($" & strCh & "$1:$" & strCh & "$24)"
            Range(strRange).FormatConditions(2).Font.ColorIndex = 6
        Next
    End Sub
      

  11.   

    To 19F:  在 strRange = strCh & "1:" & strCh & "24"’strRange用来做什么? 之前的“疑问”:
    这根本不应该算“疑问”,你要不是明白,只要在这句前加个:
    Debug.Print i, strCh
    看一下输出结果、对照一下 Excel工作表 的表头,就应该明白啊!
      “strRange用来做什么?”
      你没看到后面紧接着使用了5次strRange吗?若不用这个变量,你就得把后面的Range(strRange)替换成Range(strCh & "1:" & strCh & "24")。 这样每次都要做相同的运算。
      象我给的“150列”的代码中,你愿意让它做150×3 = 450次字符串运算,还是愿意让它做150×3×5 = 2250次字符串运算?