click and highlight

Prasanna arachchi

New Member
Joined
Jan 9, 2025
Messages
18
Office Version
  1. 365
Hi There

I have two table call costing and cost summary as shown below

I need a formular or link , When i click any combination in costing table it should highlight cells in cost summary table.

for example when i click "E7" can it automatically highlighted " O13 ( or K13:O13)

Thank you





1743391608324.png



ACA MACS Costing
Number of BeamsClear Opening WidthBeam Clear OpeningCost Summary
1500175020002250250027503000MACS Total cost
112506688101012CEMACS125150D6 $ 3,681
115006688101012CEMACS150150E6 $ 4,263
117506688101012CEMACS200150D6 $ 4,824
120006688101012CEMACS175175D6 $ 4,821
122506688101012CEMACS150250D10 $ 5,397
22500991212151518CEMACS200200D8 $ 5,885
22750991212151518CEMACS250250D15 $ 8,621
23000991212151518CEMACS350200D12 $ 9,530
23250991212151518CEMACS325250D15 $ 10,152
23500991212151518CEMACS350250D15 $ 10,791
3375012121616202024CEMACS300300D18 $ 10,902
34000, To infinity in 250mm increments12121616202024CEMACS400300D18 $ 14,451
CEMACS275275D15
Please click - Geen cells IN ABOVE TABLE to see the detail costing (costing has been completed only for these items )MACS400275D15 $ 12,400.87
 
1- I think VBA can help. Is VBA acceptable?
2- When you click E7 (2000 and 2000) why you expect cells K13:O13 (350250) highlighted? (It should be 200200 in row 19, right?)
 
Upvote 0
1- I think VBA can help. Is VBA acceptable?
2- When you click E7 (2000 and 2000) why you expect cells K13:O13 (350250) highlighted? (It should be 200200 in row 19, right?)

yes " it should be 200x200 row 9 which is correct !
VBA is acceptable as if it is simple me to handle , i am not very competent with VBA but i can manage it
thank you very much for your message
 
Upvote 0
This code is an event handler that runs automatically whenever a cell selection changes in the Excel worksheet. It highlights related data when you click on specific cells.


VBA Code:
Option Explicit
' This subroutine runs automatically when the selection changes in the worksheet
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lr As Long, st As String, fcell As Range

    ' Find the last used row in column K (by starting at bottom and moving up)
    lr = Cells(Rows.Count, "K").End(xlUp).Row
    
    ' Exit the subroutine if:
    ' 1. The selected cell(s) are NOT within range C4 to I[last row], OR
    ' 2. More than one cell is selected
    If Intersect(Target, Range("C4:I" & lr)) Is Nothing Or Target.Count > 1 Then Exit Sub
    
    ' Clear any existing color formatting in columns K and L (from row 4 to last row)
    Range("K4:L" & lr).Interior.Color = xlNone
    
    ' Create a search string by combining:
    ' - First 3 characters from column B in the selected row
    ' - First 3 characters from row 3 in the selected column
'for ex: st = "200350"
    st = Left(Cells(Target.Row, "B"), 3) & Left(Cells(3, Target.Column), 3)
    
    ' Search for the string in column K (from row 4 to last row)
    ' The "*" are wildcards meaning "any characters before/after our search string"
    Set fcell = Range("K4:K" & lr).Find("*" & st & "*")
    
    ' If a matching cell is found, color it and the cell next to it (in column L) yellow
    If Not fcell Is Nothing Then fcell.Resize(1, 2).Interior.Color = vbYellow
    
End Sub
 
Upvote 0

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