PC Review


Reply
Thread Tools Rate Thread

Change event for multiple rows

 
 
Thanks
Guest
Posts: n/a
 
      7th Aug 2008
I have a spreadsheet with 100's of rows. As dates are changed on each row I
would like a specific range in that row to change colors accordingly. How do
I make a specific column range a variable, so that if a cell changes in that
column, it then makes that row change colors of the cell changed. Here is my
code for a specific row.

Private Sub Worksheet_Change(ByVal Target As Range)

mycell = Range("m7")
If IsDate(mycell) Then

Range("A7:P7").Select

With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
Else
Range("A7:P7").Select
With Selection.Interior
.ColorIndex = 34
.Pattern = xlSolid
End With

End If

End Sub
 
Reply With Quote
 
 
 
 
Bernie Deitrick
Guest
Posts: n/a
 
      7th Aug 2008
Thanks,

If you want this to work only one cell at a time:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column <> Range("m7").Column Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub

With Cells(Target.Row, 1).Resize(1, 16).Interior
If IsDate(Target) Then
.ColorIndex = 15
.Pattern = xlSolid
Else
.ColorIndex = 34
.Pattern = xlSolid
End If
End With

End Sub


For multiple cells, you would need to loop or check the date of Target.Cells(1)

HTH,
Bernie
MS Excel MVP


"Thanks" <(E-Mail Removed)> wrote in message
news:B4022200-7EB8-4B9E-8348-(E-Mail Removed)...
>I have a spreadsheet with 100's of rows. As dates are changed on each row I
> would like a specific range in that row to change colors accordingly. How do
> I make a specific column range a variable, so that if a cell changes in that
> column, it then makes that row change colors of the cell changed. Here is my
> code for a specific row.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> mycell = Range("m7")
> If IsDate(mycell) Then
>
> Range("A7:P7").Select
>
> With Selection.Interior
> .ColorIndex = 15
> .Pattern = xlSolid
> End With
> Else
> Range("A7:P7").Select
> With Selection.Interior
> .ColorIndex = 34
> .Pattern = xlSolid
> End With
>
> End If
>
> End Sub



 
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
After Update event does not fire when pasting multiple rows intosubform datasheet view Liz O'Donoghue Microsoft Access Forms 1 30th Oct 2009 02:51 PM
Inserting Rows with the change event active KobusD Microsoft Excel Programming 2 29th Sep 2005 04:34 PM
Can't hide/unhide rows under worksheet change event? Don Wiss Microsoft Excel Programming 6 24th May 2005 11:57 PM
RE: How to change multiple rows in a table to multiple columns and on. =?Utf-8?B?T2Zlcg==?= Microsoft Access VBA Modules 0 13th Apr 2005 11:46 PM
Specify Rows and Cols for worksheet Change Event? Rich Microsoft Excel New Users 2 12th Sep 2004 01:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:24 PM.