PC Review


Reply
Thread Tools Rate Thread

choosing from drop down list

 
 
=?Utf-8?B?Sm9jaw==?=
Guest
Posts: n/a
 
      13th Nov 2007
This code will change the font on the entire row red when "PRA" appears in
column H:
Sub stantial()
Dim myRange As Range
Set myRange = Range("H8:H400")
For Each c In myRange
c.Select
If c.Value = "PRA" Then
Selection.EntireRow.Select
Selection.Font.ColorIndex = 3
End If
Next
End Sub

It works when you type in the letters, but when picked from a drop down
list, it doesn't.
Why would that be??
--
Traa Dy Liooar

Jock
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      13th Nov 2007
Sub stantial()
Dim myRange As Range, c As Range
Set myRange = Range("H8:H400")
For Each c In myRange
If c.Value = "PRA" Then
c.EntireRow.Font.ColorIndex = 3
End If
Next
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jock" <(E-Mail Removed)> wrote in message
news:A8666CAB-96AD-4D2D-B326-(E-Mail Removed)...
> This code will change the font on the entire row red when "PRA" appears in
> column H:
> Sub stantial()
> Dim myRange As Range
> Set myRange = Range("H8:H400")
> For Each c In myRange
> c.Select
> If c.Value = "PRA" Then
> Selection.EntireRow.Select
> Selection.Font.ColorIndex = 3
> End If
> Next
> End Sub
>
> It works when you type in the letters, but when picked from a drop down
> list, it doesn't.
> Why would that be??
> --
> Traa Dy Liooar
>
> Jock



 
Reply With Quote
 
=?Utf-8?B?Sm9jaw==?=
Guest
Posts: n/a
 
      13th Nov 2007
Thanks Bob, but I can't get it to work. Trying to type the text in also drew
a blank which contradicts what I wrote earlier!
I tried using "Private Sub Worksheet_Change ()" instead which would change
the text to red as required, but didn't change it back to default when "PRA"
was changed/removed.
Is there another way around this problem?
Help!
--
Traa Dy Liooar

Jock


"Bob Phillips" wrote:

> Sub stantial()
> Dim myRange As Range, c As Range
> Set myRange = Range("H8:H400")
> For Each c In myRange
> If c.Value = "PRA" Then
> c.EntireRow.Font.ColorIndex = 3
> End If
> Next
> End Sub
>
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Jock" <(E-Mail Removed)> wrote in message
> news:A8666CAB-96AD-4D2D-B326-(E-Mail Removed)...
> > This code will change the font on the entire row red when "PRA" appears in
> > column H:
> > Sub stantial()
> > Dim myRange As Range
> > Set myRange = Range("H8:H400")
> > For Each c In myRange
> > c.Select
> > If c.Value = "PRA" Then
> > Selection.EntireRow.Select
> > Selection.Font.ColorIndex = 3
> > End If
> > Next
> > End Sub
> >
> > It works when you type in the letters, but when picked from a drop down
> > list, it doesn't.
> > Why would that be??
> > --
> > Traa Dy Liooar
> >
> > Jock

>
>
>

 
Reply With Quote
 
Dan R.
Guest
Posts: n/a
 
      13th Nov 2007
Jock,

Try something like this:

Private Sub Worksheet_Change(ByVal myRange As Range)
Dim c As Range
Set myRange = Range("H8:H400")

For Each c In myRange
If c.Value = "PRA" Then
c.EntireRow.Font.ColorIndex = 3
Else
c.EntireRow.Font.ColorIndex = 0
End If
Next
End Sub

--
Dan

 
Reply With Quote
 
=?Utf-8?B?Sm9jaw==?=
Guest
Posts: n/a
 
      13th Nov 2007
That's got it. thanks Dan
--
Traa Dy Liooar

Jock


"Dan R." wrote:

> Jock,
>
> Try something like this:
>
> Private Sub Worksheet_Change(ByVal myRange As Range)
> Dim c As Range
> Set myRange = Range("H8:H400")
>
> For Each c In myRange
> If c.Value = "PRA" Then
> c.EntireRow.Font.ColorIndex = 3
> Else
> c.EntireRow.Font.ColorIndex = 0
> End If
> Next
> End Sub
>
> --
> Dan
>
>

 
Reply With Quote
 
Dan R.
Guest
Posts: n/a
 
      14th Nov 2007
That's some sloppy code I posted. Here's a better way to do it:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRange As Range

Set myRange = Range("H8:H400")

If Target.Count > 1 Then Exit Sub

If Not Intersect(Target, myRange) Is Nothing Then
If Target.Value = "PRA" Then
Target.EntireRow.Font.ColorIndex = 3
Else
Target.EntireRow.Font.ColorIndex = 0
End If
End If

End Sub

--
Dan

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
choosing mutiple values from a drop down list Trying to Finish Microsoft Access Getting Started 3 10th Mar 2009 10:12 AM
choosing multiple criteria from drop down list Trying to Finish Microsoft Access Getting Started 0 9th Mar 2009 12:08 AM
choosing multiple values from a drop down list Trying to Finish Microsoft Access Getting Started 0 8th Mar 2009 11:04 PM
Choosing multiple items in a drop down list =?Utf-8?B?U2hhZA==?= Microsoft Excel Misc 9 7th Jul 2008 06:38 PM
Auto Fill Cells, When Choosing From Drop-Down List... doc1975 Microsoft Excel Worksheet Functions 1 11th Jan 2006 02:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:28 AM.