https://www.dropbox.com/s/eulpxh8ea2...ODES.xlsm?dl=0
Sub test() Dim keyCell As Range Dim SearchRange As Range
Dim writeCell As Range, oneCell
Dim Numerals As Variant, i As Long
If Selection.Column <> 1 Then Beep: Exit Sub
Set keyCell = Selection.Cells(1, 1)
Numerals = Split(CStr(keyCell.Value), "-")
With keyCell
Set SearchRange = Range(.Cells(2, 1), .EntireColumn.Cells(Rows.Count, 1).End(xlUp))
End With
SearchRange.Offset(0, 1).Resize(, 5).ClearContents
For i = 0 To UBound(Numerals)
Set writeCell = Nothing
For Each oneCell In SearchRange
If IsNumeric(Application.Match(Numerals(i), Split(oneCell.Value, "-"), 0)) Then
Set writeCell = oneCell
Exit For
End If
Next oneCell
If Not writeCell Is Nothing Then
With writeCell
.Offset(0, Application.Match(Numerals(i), Split(.Value, "-"), 0)).Value = writeCell.Row - keyCell.Row
End With
End If
Next i
End Sub
This code above works when a combination of 5 numbers in a Cell is selected in column A, then individual numbers in the range H5 to L27 that make up the combination will be colored yellow in the cell interior.
[Private Sub Worksheet_SelectionChange(ByVal Target As Range) With Target
If .Cells.Count = 1 Then
If Not Application.Intersect(Target, Range("H:L")) Is Nothing Then
Application.EnableEvents = False
Application.Union(.Cells(1, 1), .Offset(0, 9)).Select
Application.EnableEvents = True
End If
If Not Application.Intersect(Target, Range("Q:U")) Is Nothing Then
Application.EnableEvents = False
Application.Union(.Cells(1, 1), .Offset(0, -9)).Select
Application.EnableEvents = True
End If
If Not Application.Intersect(Target, Range("Z:AD")) Is Nothing Then
Application.EnableEvents = False
Application.Union(.Cells(1, 1), .Offset(0, -9)).Select
Application.EnableEvents = True
End If
End If
End With
End Sub]
This code directly above this description works when I place a cursor on a cell within the range range H5 to L27 where ever cell the cursor rests, it will also rest on the same cell in a duplication of the range Q5 to U27 . for example when I place cursor on the H5 the cursor will show also on the Q5.
I need help in regards to adding the code just above to work with 5 simultaneous cells, so when I run the code that appears at the top the following is what i need to happen,
When I select a combination in column A, the cells interior color of 5 individual numbers that make up the selected combination, that are found in the Range H5 to L27 will be colored yellow in the cell interior.
so I need the data in the range Q5 to U27 to be interior colored yellow in the same cells ,
( what is done in one range H5 to L27, is done to the other range Q5 to U27).
The data in the Range Q5 to U27 within the cells has no involvment. Just the cells that are being colored interior cells yellow as in the first range H5 to L27.
I know 2 event codes cannot work in the same worksheet so I need help modifying the immediate code just above to work with 5 simulataneous cells and be added to the very top code to work as one event code.
Please!! Thank you