• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Bold the cell values based on criteria

nagovind

Member
Kindly advise a code to bold the cell value after selecting the cell and after running a macro with a certain condition as below:
Say the cells from A1 to A10 has the values as listed as below
if I select the cells from A1 to A10, then after running a macro, the result shall be, the cell that contains the values of 1.0. 2.0, 3.0, 4.0, 5.0 ONLY to be in BOLD and not the values after decimal >0 (not the 1.1, 1.3, 2.69, 3.59, 4.3) not to be in bold letters
60056

Regards
Govind
 
please provide a workbook so that we know more about the formatting and contents of the cells, in the meantime this might work:
Code:
Sub blah()
For Each cll In Selection.Cells
  If cll.Value = Int(cll.Value) Then cll.Font.Bold = True
Next cll
End Sub
You can do it with conditional formatting too with a formula such as =A1=INT(A1)
 
Hi p45cal
Thanks for the code and the conditional formatting formula
It works perfect
Could you please advise the code or conditional formatting even if the cell is formatted as text
Thank you

60058
 
Code for both text and numeric data:
Code:
Sub blah()
For Each cll In Selection.Cells
  If CDbl(cll.Value) = CLng(cll.Value) Then cll.Font.Bold = True
Next cll
End Sub
CF formula for numbers as text:
=VALUE(A1)=INT(VALUE(A1))
 

Attachments

  • Chandoo41694Font Bold on Selected cell int.xlsm
    14.8 KB · Views: 4
Back
Top