Link to home
Start Free TrialLog in
Avatar of Andreas Hermle
Andreas HermleFlag for Germany

asked on

Bolding cells where the cell value starts with a single or double digit number followed by a comma

Dear Experts:

For the currently selected cells I would like to apply bold to the cell where
(1) ... the cell value starts  with a single digit number, followed by a comma or ...
(2) ... the cell value starts with a double digit number, followed by a comma.

For example:

1, dummy text
2, dummy text
17, dummy text
23, dummy text

The solution could be VBA or maybe - if feasible - conditional formatting.

Thank you very much in advance.

Regards, Andreas
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, Excel built in function sometimes problem recognising numbers from a Text line so it is always advisable using a Macro / VBA code. Please try the below snippet.


Option Explicit

Sub CheckAndMake()

Dim rng As Range, cel As Range

Set rng = Range("A1:A100") ' Please change here and update Excel Range as you need


For Each cel In rng

If cel.Value <> "" Then

If IsNumeric(Left(cel.Value, 1)) = True Then

If Mid(cel.Value, 2, 1) = "," Then
cel.Font.Bold = True
End If

If Mid(cel.Value, 3, 1) = "," Then
cel.Font.Bold = True
End If


End If
End If
Next cel

End Sub
Avatar of Andreas Hermle

ASKER

Wow, Rgonzo, I am truly impressed. Very nice function! This is real professionalism.

Thank you very much for your swift and professional help.

Regards, Andreas
Hi suvmitra:

ooops, I was too quick to award points. Your code works just fine. I should have refreshed the screen before awarding points. I am really sorry.

I would have split points between the two of you, because both approaches are exactly what I wanted to have.

I am not quite sure what to do in this case?

I could turn to the forum support to ask what to do in this circumstance on the condition that Rgonzo and you agree.

Regards, Andreas
Please