?
Solved

change font color

Posted on 2011-02-20
14
Medium Priority
?
903 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:zachvaldez
  • 7
  • 6
14 Comments
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 34937223
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
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 34937232
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
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 34938154
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:zachvaldez
ID: 34938577
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
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 34938583
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
 

Author Comment

by:zachvaldez
ID: 34963316
Im getting error saying the code does not run in your veriosn. I use excel 2010?
0
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 34963542
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
 

Author Comment

by:zachvaldez
ID: 34963569
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
 

Author Comment

by:zachvaldez
ID: 34963590
I  add your code in a windows 2000 exce spreadsheetl and tried to execute it in 2010.
0
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 34963617
Try mathewpatrick solution.  It will tell you which cells have been modified... without VBA
0
 

Author Comment

by:zachvaldez
ID: 34963749
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
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 34963807
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
 

Author Comment

by:zachvaldez
ID: 35014564
I set protection.
0
 
LVL 10

Accepted Solution

by:
Christian de Bellefeuille earned 1000 total points
ID: 35017514
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question