custom functions

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Custom functions

Custom functions

resolvedResolved · High Priority · Version 2007

Diane has attended:
Excel VBA Advanced course

Custom functions

Hi
I've created a quick custom function where I want the background colour of a cell to change if another cell has the word 'yes' entered.
Is there anything obviously wrong with the below?

Function ThreeD(B As String)

If B = "Yes" Then

ThreeD.Interior.Color = RGB(127, 127, 127)

Else

ThreeD = 0

End If

End Function

Thanks! Diane

RE: custom functions

Hi Diane

Thanks for the question

It is not possible to use a function to achieve what you are attempting

I have created the following sub procedurenwhich you can adapt to solve your problem

Sub ThreeD()

Dim B As String
B = Cells(1, 1).Value

If B = "Yes" Then

Cells(1, 1).Interior.Color = RGB(127, 127, 127)
Else
Cells(1, 1).Interior.Color = RGB(0, 0, 0)

End If

End Sub


Hope this helps

Regards

Stephen

Tue 23 Feb 2010: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Change the Default Width of All Columns in Excel 2010

If you want to change the width of the columns in your Excel 2010 spreadsheet, making them either larger or smaller, here's how:

In the Cells group on the Home tab, click Format.

Hover over the section called Cell Size and a drop down list will appear, select Default Width from this list.

In the Standard Width dialog box, enter the size you want to set as the default width and click OK.

View all Excel hints and tips


Server loaded in 0.07 secs.