worksheet events and a little more help

T

tinkerbellsmyhoe

Hello,

I'll start with the code i am using already:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 6 And Target.Row > 3 And Target.Row < 256 And
Target.Value = "F" Then
Worksheets("Test Results").Select
Worksheets("Test Results").Cells(2, Target.Row + 1).Select


End If


If Target.Count > 1 Then Exit Sub
If Target.Column = 7 And Target.Row > 3 And Target.Row < 256 And
Target.Value = "F" Then
Worksheets("Test Results").Select
Worksheets("Test Results").Cells(13, Target.Row + 1).Select
End If


If Target.Count > 1 Then Exit Sub
If Target.Column = 8 And Target.Row > 3 And Target.Row < 256 And
Target.Value = "F" Then
Worksheets("Test Results").Select
Worksheets("Test Results").Cells(24, Target.Row + 1).Select
End If


If Target.Count > 1 Then Exit Sub
If Target.Column = 9 And Target.Row > 3 And Target.Row < 256 And
Target.Value = "F" Then
Worksheets("Test Results").Select
Worksheets("Test Results").Cells(35, Target.Row + 1).Select
End If


If Target.Count > 1 Then Exit Sub
If Target.Column = 10 And Target.Row > 3 And Target.Row < 256 And
Target.Value = "F" Then
Worksheets("Test Results").Select
Worksheets("Test Results").Cells(46, Target.Row + 1).Select
End If


If Target.Count > 1 Then Exit Sub
If Target.Column = 11 And Target.Row > 3 And Target.Row < 256 And
Target.Value = "F" Then
Worksheets("Test Results").Select
Worksheets("Test Results").Cells(57, Target.Row + 1).Select
End If


If Target.Count > 1 Then Exit Sub
If Target.Column = 12 And Target.Row > 3 And Target.Row < 256 And
Target.Value = "F" Then
Worksheets("Test Results").Select
Worksheets("Test Results").Cells(68, Target.Row + 1).Select
End If
If Target.Count > 1 Then Exit Sub
If Target.Column = 13 And Target.Row > 3 And Target.Row < 256 And
Target.Value = "F" Then
Worksheets("Test Results").Select
Worksheets("Test Results").Cells(77, Target.Row + 1).Select
End If


End Sub


I would like to insert a piece of code into each if statement to change



the target cell + the next 10 rows in that column to a red font. then
change the font back to black (or default) after the selection changes.



i have once again given my best shot and the best i can get (once i get



passed the runtime errors), is for nothing to happen.


Thanks in advance,


Mike C.
 
B

Bob Phillips

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

With Target
If .Count > 1 Then Exit Sub
If .Row > 3 And .Row < 256 And .Value = "F" Then
If .Font.ColorIndex = 3 Then
.Resize(10, 1).Font.ColorIndex = xlColorIndexAutomatic
Else
.Resize(10, 1).Font.ColorIndex = 3 'red
End If
If .Column >= 6 And .Column <= 13 Then
Worksheets("Test Results").Select
Worksheets("Test Results").Cells(2 + (.Value - 6) * 11, .Row
+ 1).Select
End If
End If
End If
End With

End Sub

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
D

Don Guillett

try this
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row < 4 Or Target.Column < 7 Then Exit Sub

Columns(Target.Column).Font.ColorIndex = 0
Target.Resize(10, 1).Font.ColorIndex = 3

'MsgBox Target.Column
x = 2 + (Target.Column - 6) * 11
MsgBox x
Application.Goto Sheets("Test Results").Cells(x, Target.Row + 1)
End Sub
 
T

tinkerbellsmyhoe

thanks for the replies gentlemen. i tried both pieces of code with my
existing code and i having porblems with both. the code from Don
doesnt spit out any errors but it doesnt seem to do anything. please
help again.
 
B

Bob Phillips

What are the problems with mine?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
D

Don Guillett

both should work. You may want to change mine from

Columns(Target.Column).Font.ColorIndex = 0
to
cells.Font.ColorIndex = 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top