change font color

I have a spreadsheet to email to users for edit. When they open it,id like to default the font to calibri,blue and bold. This will let me know the cells they edit
zachvaldezAsked:
Who is Participating?
 
Christian de BellefeuilleConnect With a Mentor ProgrammerCommented:
i'm still waiting for a file sample.... but try this.  It will unprotect your sheet, modify the font, and protect it again.  

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Sh.Unprotect "YourPassword"
    With Target
        .Font.Name = "Calibri"
        .Font.Bold = True
        .Font.Color = vbBlue
    End With
    Sh.Protect "YourPassword"
End Sub 

Open in new window



0
 
Christian de BellefeuilleProgrammerCommented:
Here is a sample.  Just set your color to blue and font to Calibri in this sample, and it will work.
Add this code in "This Workbook"


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    With Target
        .Font.Bold = True
        .Font.Underline = True
        .Font.Name = "Time New Roman"
        .Font.Color = vbRed
    End With
End Sub
0
 
Christian de BellefeuilleProgrammerCommented:
I've forgot... remove the "underline" since you didn't asked for it.

So it should look like this:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    With Target
        .Font.Bold = True
        .Font.Name = "Calibri"
        .Font.Color = vbBlue
    End With
End Sub

ChangeFontColor.xlsm
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Patrick MatthewsCommented:
zachvaldez,

You may want to consider setting the workbook to be "shared" with track changes enabled.  (Track changes can only be done on shared workbooks.)

Share workbook should never, in my opinion, be used to allow multiple users to edit a single workbook at the same time, but should rather only be used to enable track changes.

Patrick
0
 
zachvaldezAuthor Commented:
I'm developing the template using version 2000 to avoid any compatibility with the latest 2010 version. Do you think the code can be applied
0
 
Christian de BellefeuilleProgrammerCommented:
The code could be applied.  I don't have the 2000 version beside me to test it, but you can give it a try.  These things are not new really.
0
 
zachvaldezAuthor Commented:
Im getting error saying the code does not run in your veriosn. I use excel 2010?
0
 
Christian de BellefeuilleProgrammerCommented:
What is the error message?  I get no error message and i'm using Excel 2010.

I've noticed a little glitch.  Bold is not set because i change the font name after so these lines has to be swapped like this:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    With Target
        .Font.Name = "Calibri"
        .Font.Bold = True
        .Font.Color = vbBlue
    End With
End Sub

Open in new window


But as i said, it doesn't trigger any error.  Post your file if you need some help, because i suspect that you did something wrong.
0
 
zachvaldezAuthor Commented:
Is it possible to have this implemented without use of macro. Some users are not familiar or are overwhelmed when they see such messages as 'please enable macros.....' particularly when setting security to medium. I'd decided to do it without any macro calls. What's alternative?
0
 
zachvaldezAuthor Commented:
I  add your code in a windows 2000 exce spreadsheetl and tried to execute it in 2010.
0
 
Christian de BellefeuilleProgrammerCommented:
Try mathewpatrick solution.  It will tell you which cells have been modified... without VBA
0
 
zachvaldezAuthor Commented:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    With Target
        .Font.Name = "Calibri"
        .Font.Bold = True
        .Font.Color = vbBlue
    End With
End Sub

two things happen unexpectedly as I swapped the lines even though i executed in 2010
.. Since I use this on a blank template.. all  fonts are now blue in the dot file
.. got error  '1004' unable to set name property of font class when i entered values in cell
0
 
Christian de BellefeuilleProgrammerCommented:
You never told me that you would do that on a template!   I said to put that on the specific workbook where you need to see those changes.  Of course if you do that in a template it will apply to all workbooks.  

(And it has nothing to do with the swap of lines.  The swap i asked to do is because when you typed something, it was turning BOLD, then when changing the font name on the next line, it was reseting the bold!)

Post your workbook please... i need to see what you have done.  The Font.Name is NOT a read only property.  You probably have set protection on your sheet or something like that...
0
 
zachvaldezAuthor Commented:
I set protection.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.