Solved

change font color

Posted on 2011-02-20
14
877 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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
 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

776 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