how add red oval shapes around the values based on selected range or separated cells

Mussa

Active Member
Joined
Jul 12, 2021
Messages
251
Office Version
  1. 2019
  2. 2010
hello
I would add red oval shape into cells based on select the range or specific separated cells which contains any value .
see some picture when select some ranges or cells .with considering the oval shape doesn't be outside the cell should fit into cell
1.PNG


2.PNG




3.PNG


expected result
4.PNG

thanks
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try this:

VBA Code:
Sub AddRedOval()
  Dim shp As Shape
  Dim c As Range, r As Range
  
  ActiveSheet.DrawingObjects.Delete
  Set r = Selection
  For Each c In r
    If c.Value <> "" Then
      Set shp = ActiveSheet.Shapes.AddShape(msoShapeOval, c.Left, c.Top, c.Width, c.Height)
      shp.Fill.Transparency = 1
      shp.Line.ForeColor.RGB = RGB(255, 0, 0)
      shp.Line.Weight = 1
    End If
  Next
End Sub
 
Upvote 0
Solution
very excellent ! but I need when I select specific cells and highlighted and move to others selected cells when higlighted the new selected cell .shouldn't delete the shape from old selected cell . every time select cell should add the shape . it deosn't delete it except in one cas as the code does when I don't select cell then it delete all shape from all cells have been selected .
 
Upvote 0
Delete this line and try again

ActiveSheet.DrawingObjects.Delete
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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