Results 1 to 5 of 5

Thread: Macro to find the min value of the rows

  1. #1
    Join Date
    May 2011
    Posts
    220

    Macro to find the min value of the rows

    I want the code that will find the min value in the particular coloum and once it gets the min value should clear the contents of the other cells.For example if i have the dates in the coloum and i want to find the minimum dates and then want to clear other cells based on the results
    For example the dates are
    200906
    200905
    200808
    200801
    200710
    200705
    200702
    I want to find the min of these dates and clear the cells for the min value only

  2. #2
    Join Date
    Jun 2009
    Posts
    1,518

    Re: Macro to find the min value of the rows

    For your problem :

    his is the macro but it is in the VBeditor,you must first delete the coloum and then again run the macro "min" in the VBeditor

    Code:
    Sub TotalTableCellValues()
       Dim cTable1Cell As Cell
       Dim cTable2Cell As Cell
       Dim cSumCell As Cell
       Dim iCellTotal As Long
       ' Set variable equal to cell A1 of table 1.
       Set table1Cell = ActiveDocument.Tables(1).Cell(Row:=1, Column:=1)
       ' Set variable equal to cell A1 of table 2.
       Set table2Cell = ActiveDocument.Tables(2).Cell(Row:=1, Column:=1)
       ' Set variable equal to cell A2 of table 2.
       Set cSumCell = ActiveDocument.Tables(2).Cell(Row:=2, Column:=1)
       ' Calculate totals
       iCellTotal = Val(table1Cell.Range.Text) + Val(table2Cell.Range.Text)
       ' Insert result of calculation into cell A2 of Table 2.
       cSumCell.Range.Text = iCellTotal
    End Sub

  3. #3
    Join Date
    Nov 2008
    Posts
    1,514

    Re: Macro to find the min value of the rows

    I f u have a spreadsheet and you want to find the lowest value and highlight the lowest number in each row then use this macro
    Code:
    Sub HTH()
    Dim r As Range
    i = Application.WorksheetFunction.Min(ActiveCell.EntireRow)
    ActiveCell.EntireRow.Find(What:=i, LookIn:=xlValues).Select
    End Sub
    hope this will help you

  4. #4
    Join Date
    May 2008
    Posts
    913

    Re: Macro to find the min value of the rows

    I am writing a code that will find the lowest value of each row and then it will change the background color of the particular row,it will only change the color of the lowest cells,I have written a long VBA code it is working but the code is not portable and if some more coloums are added then the changes that must be made to the "if statements" are long . The most basic example for the same you can test by using conditional formatting which does not need scripting.

  5. #5
    Join Date
    Nov 2008
    Posts
    1,022

    Re: Macro to find the min value of the rows

    If you have the rows of data and want to highlight them then the easiest way to do this is by using the conditional formatting
    first highlight the row/range of the data then after that go to format menu and select conditional formatting
    cell value =MIN(highlight the row/range)
    after then choose the pattern color
    this should help you,but if you have a lt of rows then it is very complicated but it works

Similar Threads

  1. Replies: 6
    Last Post: 23-07-2011, 01:05 AM
  2. How to find particular column name by using Excel Macro
    By Eleder in forum Windows Software
    Replies: 5
    Last Post: 05-04-2011, 10:49 PM
  3. Replies: 4
    Last Post: 01-04-2011, 02:00 AM
  4. How To Copy Rows having Colored Cells by Macro
    By dogaman in forum Windows Software
    Replies: 3
    Last Post: 16-11-2010, 03:23 AM
  5. Excel macro variable to delete rows
    By JPGargoyle in forum Windows Software
    Replies: 2
    Last Post: 22-06-2009, 11:26 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,727,406,572.91441 seconds with 17 queries