Solved

change font color

Posted on 2011-02-20
14
859 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:cdebel
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:cdebel
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 92

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
 

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:cdebel
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:cdebel
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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:cdebel
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:cdebel
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:
cdebel earned 250 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now