Help with simple(?) VBA function

D

Dick Merryman

I'm trying to selectively BOLD cells by the use of a User-Defined function.
No joy.

The VBA Help topics suggest something like this:

Function Bold()
Worksheets("Sheet1").Range("A1:A5").Font.Bold = True
End Function

When I try to use it the referenced cells are not changed and the function
returns "0".

Can anyone point this VBA neophyte in the right direction?

Thanks,

-Dick-
 
F

Frank Kabel

Hi dick
no chance to do this. Functions are not able to change the Excel
environment. E.g. they cannot change other cells or formats. They can
only return values.
 
G

Gord Dibben

Dick

Functions cannot change formatting, only return results.

Try

Sub Bold()
Worksheets("Sheet1").Range("A1:A5").Font.Bold = True
End Sub

Gord Dibben Excel MVP
 
D

Dick Merryman

Guys, thanks for the responses. I did not know that functions were so
limited.

Let me tell you what I am trying to do and maybe you'll have some
suggestions.

I have a spreadsheet that lists manufacturing production options and their
associated costs. What I want to do is select various options by putting an
"x" next to the option and having Excel highlight the option description in
bold and sum the cost into the grand total. I have it all working except
for the bold highlighting.

Any help??

-Dick-
 

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