Highlight offset 8th row 3 values, from the selected cell

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
Hello,

I requiresome solution to be highlighted offset 8th row 3 values, from the selected cell
Range to beselected in columns K:P, and highlighted range to be selected in columns C:H

For example...
If I selectK16, highlight the C14:C16
If I selectM31, "clear the highlighted range C14:C16" and highlight the E29:E31
If I selectP47, "clear the highlighted range E29:E31" and highlight the H45:H47

Note: ifselection is out of columns K:P, clear all highlights from columns C:G

Exampledata....


Book1
ABCDEFGHIJKLMNOPQ
1
2
3
4
5n1n2n3n4n5n6n1n2n3n4n5n6
630111342184304542
7292745331938212422
8234652233111433
921245124727211324
1046351882112211234
1135213745147311244
121815329227130242
133811465139231342
14454230938252422
154510186310332424
163162221146321425
17
18
19
20n1n2n3n4n5n6n1n2n3n4n5n6
2130111342184304542
22292745331938212422
23234652233111433
2421245124727211324
2546351882112211234
2635213745147311244
271815329227130242
283811465139231342
29454230938252422
304510186310332424
313162221146321425
32
33
34
35
36n1n2n3n4n5n6n1n2n3n4n5n6
3730111342184304542
38292745331938212422
39234652233111433
4021245124727211324
4146351882112211234
4235213745147311244
431815329227130242
443811465139231342
45454230938252422
464510186310332424
473162221146321425
48
49
Sheet1



Thank youall
Excel 2000
Regards,
Moti
 
Last edited:
Is it? I presumed if you selected a cell near the top of the right-hand filled range, or if you selected a cell in the title row itself, that you would not want the selection in the other filled range to color the title row or blank cells above it. Mick's code colors those cells for such a selection... the following SelectChange event accounts doesn't.
Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Dim TopRow As Long, Cell As Range, Rng As Range, IntersectRng As Range
  Range("C:H,K:P").Interior.ColorIndex = xlColorIndexNone
  Set Rng = Intersect(Target, Columns("K:P"))
  If Not Rng Is Nothing Then
    TopRow = Rng.CurrentRegion.Row
    For Each Cell In Rng
      If IsNumeric(Cell.Value) And Cell.Value <> "" Then
        Cell.Interior.Color = vbYellow
        Intersect(Cell.CurrentRegion.Offset(1, -8), Cell.Offset(-2, -8).Resize(3)).Interior.Color = vbYellow
      End If
    Next
  End If
End Sub[/TD]
[/TR]
</tbody>[/TABLE]
Hello Rick Rothstein, after Appling your function when I select any cell in the column K:P, it start flickering, and to exit code I need to press escape key after this is what happen. I did select the cell M12


Book1
ABCDEFGHIJKLMNOPQ
1
2
3
4
5n1n2n3n4n5n6n1n2n3n4n5n6
630111342184304542
7292745331938212422
8234652233111433
921245124727211324
1046351882112211234
1135213745147311244
121815329227130242
133811465139231342
14454230938252422
154510186310332424
163162221146321425
17
18
19
Sheet1


Please could you check?

Thank you for your help

Kind Regards,
Moti
 
Last edited:
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hello Rick Rothstein, after Appling your function when I select any cell in the column K:P, it start flickering, and to exit code I need to press escape key after this is what happen. I did select the cell M12

I am not sure what to tell you as my code does not do what you are describing for me... when I pick cell M12, cells E10:E12 highlight in yellow without any flickering (and the same for any other cell with a number in it in Columns K:P).
 
Upvote 0
I am not sure what to tell you as my code does not do what you are describing for me... when I pick cell M12, cells E10:E12 highlight in yellow without any flickering (and the same for any other cell with a number in it in Columns K:P).
Hello RickRothstein, I tried with a new sheet no luck, thank you for looking in to it. I adapted Mick code with my necessity and it is working ok. I have a next question please need your support how can I combine two " Private SubWorksheet_SelectionChange(ByVal Target As Range)" in to the one sheet

Code1
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count = 1 Then
If Not Intersect(Target, Range("CO:DB")) Is Nothing Then
    If Target <> "" Then
        Range("C6:P5006").Interior.ColorIndex = xlNone
        Target.Offset(-2, -90).Resize(3).Interior.Color = vbYellow
    End If
ElseIf Intersect(Target, Columns("CO:DB")) Is Nothing Then
     Range("C6:P5006").Interior.ColorIndex = xlNone
End If
End If
End Sub

Code2
Code:
Private Sub Worksheet_SelectionChange_1(ByVal Target As Range)
If Target.Count = 1 Then
If Not Intersect(Target, Range("CF:CF")) Is Nothing Then
    If Target <> "" Then
        Range("C6:P5006").Interior.ColorIndex = xlNone
        Target.Offset(0, -81).Resize(1, 14).Interior.Color = vbYellow
        Target.Offset(-2, -81).Resize(1, 14).Interior.Color = vbYellow
    End If
ElseIf Intersect(Target, Columns("CF:CF")) Is Nothing Then
     Range("C6:P5006").Interior.ColorIndex = xlNone
End If
End If
End Sub

Thank you for your help

Kind Regards,
Moti
 
Last edited:
Upvote 0
Hello Rick Rothstein, after Appling your function when I select any cell in the column K:P, it start flickering, and to exit code I need to press escape key after this is what happen. I did select the cell M12

Hello RickRothstein, I tried with a new sheet no luck,

I cannot think of any reason why my code won't work for you. Can you do me a favor and send me a copy of your workbook so that I can watch my code work against your actual data? My email address is...

rick DOT news AT verizon DOT net
 
Upvote 0
I cannot think of any reason why my code won't work for you. Can you do me a favor and send me a copy of your workbook so that I can watch my code work against your actual data? My email address is...

rick DOT news AT verizon DOT net
Hello Rick, please check workbook sent

Kind Regars,
Moti
 
Upvote 0
Hello Rick, please check workbook sent
I got the file, opened it, enabled macros and... the code worked perfectly, it highlighted the correct cells exactly as it was supposed to. I opened originally in XL2010 (the latest version I currently have installed) so, thinking it may be a version issue, I opened it in XL2003 (the earliest version I own) and, again, the code worked perfectly for me. I cannot duplicate the problem you say you are having even when using your original file. Just out of curiosity, what version of Excel are you using?
 
Upvote 0
I got the file, opened it, enabled macros and... the code worked perfectly, it highlighted the correct cells exactly as it was supposed to. I opened originally in XL2010 (the latest version I currently have installed) so, thinking it may be a version issue, I opened it in XL2003 (the earliest version I own) and, again, the code worked perfectly for me. I cannot duplicate the problem you say you are having even when using your original file. Just out of curiosity, what version of Excel are you using?
Hello Rick Rothstein, it is mention in post#1 in the left of bottom "Excel 2000". I believe that code has no issue; it could be the version problem.

Could you please check post#13, is it possible to use 2 function in the one worksheet

Thank you

Kind Regards,
Moti
 
Upvote 0

Forum statistics

Threads
1,215,200
Messages
6,123,611
Members
449,109
Latest member
Sebas8956

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top