Solved

Excel, make a field bold if a condition is met

Posted on 2013-12-18
3
336 Views
Last Modified: 2013-12-21
Hi,

Do I have to write some VB in a macro to accomplish the following ? and if so am I along the right lines of thinking here.

1) Range l3-l17 has times in it.  
2) I need to get the earliest time so a (Min function)
3) Then in the Range b3-j17 i have various times in each cell

If any of the times in the b3-j17 range is >= the min value in Range i3-i17 the value in that cell needs to be bold.

so from research I came up with this..

a) is it correct
b) where do i place it in excel macros. ?

Sub BoldHours()

    Application.ScreenUpdating = False
    Dim c As Long

    For Each c = 2 to 10 ' this covers column b to J

        ActiveSheet.AutoFilterMode = False

        With Range("b3:j17").Offset(0, c - 1)

            .Font.Bold = False
            .AutoFilter Field:=1, Criteria1:=">=min( l3:l17)"
            .Font.Bold = True
        End With

    Next

    ActiveSheet.AutoFilterMode = False
    Application.ScreenUpdating = True

End Sub
0
Comment
Question by:c45
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 500 total points
ID: 39728381
Hi,

Do I have to write some VB in a macro to accomplish the following

No, you do not need Visual Basic for Applications code (within a macro) to accomplish this.

You could use Conditional Formatting, for example:
Conditional Formatting applied
However, are you sure you wish to set every cell to Bold that is greater than, or equal to, the minimum time value in that range?

If every cell has a time value within it, then every cell will be greater than, or equal to, the minimum value.  Every cell will be Bold!

In case this is not what you wanted, I have attached a workbook that just sets every cell that is greater than the minimum time value to Bold.  The cell that is equal to the minimum value is not set to Bold.

If you did want every cell to be Bold that matches the condition, then simply change the greater than sign (>) to greater than, or equal to (>=) in the Conditional Formatting Condition.

BFN,

fp.
Q-28321699.xls
0
 

Author Comment

by:c45
ID: 39732579
Hi, Thanks,

I mis spoke, The Min Value has to be from a range in another cell group.

See attached.

I wish to examine the cells B1-j15 and see if any of the times are greater than the earliest time in cells l1:l15

if they are they need to be bold or change color.

I have changed the colors of the cells manually to show what the correct ones should be.

thanks
helpq.xlsx
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 39733338
You have closed the question (grading as a 'B') without allowing me time to respond.

I am sorry I was not able to return to reply immediately upon your re-evaluation of your requirements, but I am now presuming you no longer wish to receive any assistance.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question