icolor targetrange

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 » Icolor, target,range

Icolor, target,range

resolvedResolved · Medium Priority · Version 2003

Scott has attended:
Access Introduction course
Access Intermediate course
Access Advanced course
Access VBA course

Icolor, target,range

How do I get vba to shade a cell using VBA dependant on the text in another column (typically the column immediately to the right?

RE: icolor, target,range

Hi Scott

The code below looks at text in column B of a workbook and whatever text it finds it colours the adjacent cell in column A either Green, Red or leaves the cell Uncoloured if the words don't match.

Sub ColourFormatByText()

Dim intCounter As Integer

For intCounter = 2 To 20

Select Case Cells(intCounter, 2).Value

Case "Hello"
Cells(intCounter, 1).Interior.ColorIndex = 3

Case "Goodbye"
Cells(intCounter, 1).Interior.ColorIndex = 4

Case Else
Cells(intCounter, 1).Interior.ColorIndex = xlNone

End Select

Next intCounter

End Sub


I have attached a Workbook so you can see the code at work

Hope this helps

Carlos

Attached files...

FormatCells.xls

RE: icolor, target,range

Hi Carlos,
I can see what it should do, but no joy on my pc! I have the VBA add-ins selected, could I be missing something?

Rgds

Scott

RE: icolor, target,range

Hi Scott

Are you saying the workbook I sent you is not working on your PC?

Regards

Carlos

RE: icolor, target,range

Hi Carlos,
Yes, coming down to Southwark Tuesday/Wednesday for Access courses if you are about?

Regards
Scott

RE: icolor, target,range

Hi Scott

No I'm not in Southwark next week. I am training at other sites.

Since the workbook I sent you does not work on your PC, there seems to be a software problem with Excel on your PC and you may need to contact your IT department to fix it.

Regards

Carlos

RE: icolor, target,range

Hi Carlos,

RE: icolor, target,range

Hi Carlos,

RE: icolor, target,range

Hi Carlos,

RE: icolor, target,range

Hi Carlos,

RE: icolor, target,range

Hi Carlos, I tried this down at Southwark on one of your machines with Raj stood next to me and it still doesn't work!
Any Ideas?
Regards

Scott

RE: icolor, target,range

Hi Carlos,

RE: icolor, target,range

Hi Carlos,

Thu 4 Jun 2009: 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:

Apply currency format quickly in Excel

To quickly apply the currency format to cell in your spreadsheet, select (highlight) the cells you wish to apply currency format to, then use Ctrl + Shift + $

This will apply a pounds symbol even though the $ key is pressed.

View all Excel hints and tips


Server loaded in 0.09 secs.