Avatar of Andreas Hermle
Andreas Hermle
Flag 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
Microsoft Excel

Avatar of undefined
Last Comment
Andreas Hermle

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Rgonzo1971

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
suvmitra

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
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
Andreas Hermle

ASKER
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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck