Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Setup / November 2006

Tip: Looking for answers? Try searching our database.

Condional Formatting with MACRO

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anift - 10 Nov 2006 13:29 GMT
Hello all
I would like to hightlight a row based on a value in a cell. I know it is
possible. I just don't know how to go about doing. i'd like to use vba if
possible.
In Column B1 and down, I have open, close, etc. If Open is selected, I would
like that row to be highlighted. Could someone help me out???

Thanks
Bob Phillips - 11 Nov 2006 00:31 GMT
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "B:B"

   If Not Intersect(Target, rang(WS_RANGE)) Is Nothing Then
       If Target.Value = "Open" Then
           Target.EntireRow.Interior.ColorIndex = 38
       Else
           Target.EntireRow.Interior.ColorIndex = xlColorIndexNone
       End If
   End If

End Sub

This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

> Hello all
> I would like to hightlight a row based on a value in a cell. I know it is
[quoted text clipped - 4 lines]
>
> Thanks
Anift - 11 Nov 2006 04:17 GMT
Hello Bob,
Thanks for the response, i really appreciate..
But there is something wrong in this code

I am getting error on line  " If Not Intersect(Target, rang(WS_RANGE)) Is
Nothing Then"
Its highlighing the word "rang",
Can we do anything about it?

any help will be appreciated.

Thanks

> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> Const WS_RANGE As String = "B:B"
[quoted text clipped - 31 lines]
> >
> > Thanks
Bob Phillips - 11 Nov 2006 09:52 GMT
Sorry, missed an e

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "B:B"

   If Not Intersect(Target, Range(WS_RANGE)) Is Nothing Then
       If Target.Cells.Count = 1 Then
           If Target.Value = "Open" Then
               Target.EntireRow.Interior.ColorIndex = 38
           Else
               Target.EntireRow.Interior.ColorIndex = xlColorIndexNone
           End If
       End If
   End If

End Sub

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> Hello Bob,
> Thanks for the response, i really appreciate..
[quoted text clipped - 44 lines]
> > >
> > > Thanks
Anift - 12 Nov 2006 05:08 GMT
Thanks bob, I figured it out..
thanks a lot, it helped
Kudos to u

> Sorry, missed an e
>
[quoted text clipped - 63 lines]
> > > >
> > > > Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.