icolor targetrange
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Icolor, target,range

Icolor, target,range

resolvedResolved · Medium Priority · Version 2003

replyReply Wed 20 May 2009, 14:06Delegate Scott said...

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?

For upcoming training course dates see: Pricing & availability

replyReply Fri 22 May 2009, 13:46Trainer Carlos said...

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

replyReply Fri 22 May 2009, 20:14Delegate Scott said...

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

replyReply Wed 27 May 2009, 11:14Trainer Carlos said...

RE: icolor, target,range

Hi Scott

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

Regards

Carlos

replyReply Thu 28 May 2009, 21:06Delegate Scott said...

RE: icolor, target,range

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

Regards
Scott

replyReply Fri 29 May 2009, 09:12Trainer Carlos said...

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

replyReply Fri 5 Jun 2009, 09:47Delegate Scott said...

RE: icolor, target,range

Hi Carlos,

replyReply Fri 5 Jun 2009, 09:47Delegate Scott said...

RE: icolor, target,range

Hi Carlos,

replyReply Fri 5 Jun 2009, 09:47Delegate Scott said...

RE: icolor, target,range

Hi Carlos,

replyReply Fri 5 Jun 2009, 09:47Delegate Scott said...

RE: icolor, target,range

Hi Carlos,

replyReply Fri 5 Jun 2009, 09:49Delegate Scott said...

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

replyReply Fri 5 Jun 2009, 09:47Delegate Scott said...

RE: icolor, target,range

Hi Carlos,

replyReply Fri 5 Jun 2009, 09:47Delegate Scott said...

RE: icolor, target,range

Hi Carlos,

Thu 4 Jun 2009: Automatically marked as resolved.

 

Please browse our web site to find out more about
excel training class and other Microsoft training courses.

Excel tip:

Move or Highlight Cells

Use any of your movement keys, cursor, Home, End, PgUp or PgDn to highlight cells rows or columns by holding down the Shift key as you move.

Use in combination with the Ctrl key for quicker movements.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard