Control button to change cell(s) colour

Boyyobach

New Member
Joined
Aug 31, 2020
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I've got a spreadsheet where I'm using it to visually display data on a "plot plan".

I have various shapes on the plan and set up Message boxes so that they display what they are.

This is where I've go stuck, I also want the corresponding row to be highlighted ( the Row contains more data)

So basically what I want is:

- When the shape is clicked the corresponding row to be highlighted
- When the same shape is clicked again the row is "un"highlighted

Can this be done?

Any help would be appreciated.

Cheers

Cammy
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hello,

There must be a better way than this, specially if you have many 'shapes'. You can assign a macro to each shape

VBA Code:
Sub SHAPE_1_COLOUR()
    If Range("A5").Interior.Color = vbRed Then
        Range("A5:D5").Interior.ColorIndex = xlNone
    Else
        Range("A5:D5").Interior.Color = vbRed
    End If
End Sub

Any use?
 
Upvote 0
You could assign this to each shape & it will fill the row containg the topleft corner of the shape
VBA Code:
Sub Boyyoback()
   With ActiveSheet.Shapes(Application.Caller).TopLeftCell
      If Range("A" & .Row).Interior.Color = rgbGreen Then
         Rows(.Row).Interior.ColorIndex = xlNone
      Else
         Rows(.Row).Interior.Color = rgbGreen
      End If
   End With
End Sub
 
Upvote 0
Hello,

There must be a better way than this, specially if you have many 'shapes'. You can assign a macro to each shape

VBA Code:
Sub SHAPE_1_COLOUR()
    If Range("A5").Interior.Color = vbRed Then
        Range("A5:D5").Interior.ColorIndex = xlNone
    Else
        Range("A5:D5").Interior.Color = vbRed
    End If
End Sub

Any use?

Good morning onlyadrafter, cheers for the quick reply

Ok added in a new shape to test the above code, and it works.

Brilliant work.

Cheers

Cammy
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,873
Members
449,056
Latest member
ruhulaminappu

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