Format Help BOLD year in a specific vehicle application Column

  • Thread starter mobile electronics installer
  • Start date
M

mobile electronics installer

Basically I am a mobile electronics installer. I have created an inventory of
what metra kits (www.metraonline.com) we have, where they are stored, and
specific vehicle application. Now what I would like is the year to be bolded.
It varies from line to line but most are like this "Hyndia Excel 86-89
Mitsubishi Precis 87-89" or "Mazda Multi Kit 86-95 Dash Bezel Mount" and
"Honda Accord 03-Up" Is it possible to custom format this to diffientiate
between the Make model, and the year?
 
R

Roger Govier

Hi

You can do it manually by just highlighting the relevant characters in
the formula bar and pressing the Bold icon.
For a large list of cells, you would need to use some VBA code to
achieve this.

If you mark the range of cells on your sheet containing these entries,
then run the code below, it should carry out the task for you.

Sub BoldYear()
Dim test As String, First As Integer, Last As Integer, i As Integer,
Length As Integer
Dim c As Range
For Each c In Selection
test = c.Value
' find first numeric
For i = 1 To Len(test)
If IsNumeric(Mid(test, i, 1)) Then
First = i
Exit For
End If
Next

'find last numeric
For i = First + 1 To Len(test)
If Mid(test, i, 1) <> "-" Then
If Not IsNumeric(Mid(test, i, 1)) Then
Last = i
Exit For
End If
End If
Next

If Last = 0 Then Last = i
Length = Last - First
' now embolden from first to last characters
With c.Characters(Start:=First, Length:=Length).Font
.FontStyle = "Bold"
End With
First = 0: Last = 0: Length = 0
Next c
End Sub


You can copy the code and paste it into your Visual Basic Editor
(VBE) in a Standard Module located in your file.

To do this,

Alt + F11 (open VBE)
Ctrl + R (open Project Explorer)
Select the file name on the left
Insert > Module
Paste code in Module

David McRitchie has lots of useful help on his site at
http://www.mvps.org/dmcritchie/excel/install.htm
http://www.mvps.org/dmcritchie/excel/getstarted.htm


--
Regards

Roger Govier


"mobile electronics installer" <mobile electronics
(e-mail address removed)> wrote in message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top