Circle the cell if the figure exceeds 3

shyam

Active Member
Joined
Jul 18, 2005
Messages
302
I have 4 columns wherein the details are somewhat given below. Is there any way, wherein the figures under the column "No. of times" can be circled if it goes above 3.

Excel Workbook
CDEF
19DateTimeMin.No. of times
20Apr-08
21Wed - 09-Apr-20082:42 & 2:494 & 232
22Thu - 10-Apr-200803:2151
23Fri - 11-Apr-200810:27, 7:24 p.m., 7:39 & 7:401, 8, 1 & 124
24Tue - 15-Apr-200810:26, 10:31, 10:32, 11:26 & 11:306, 2, 4, 4, 25
Sheet1
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
59,294
Office Version
  1. 365
Platform
  1. Windows
shyam

Does it need to be a cirle rather than just, say, colouring the cell with Conditional Formatting?

Also, how are the cells being populated? (eg manual entry, formula result)

Is vba solution okay?

Do the cells already have any Data Validation?

Is the circling process a one-off or does it need to be dynamic so if column F cells change, the circles automatically change?
 
Upvote 0

shyam

Active Member
Joined
Jul 18, 2005
Messages
302
Hello Mr.Peter,

Presently, the entry is a manual entry. but if the result can be achieved through a formula, then nothing like it. Either it can be coloured or should reflect automatically.

The cell does not have any data validation.

If the number of entries in column E varies, i.e. the counting, the column F should also change automatically and so also the circle alongwith it.

Tks n rgds

Shyam
 
Upvote 0

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
59,294
Office Version
  1. 365
Platform
  1. Windows
I'm not quite sure I have understood, but try this. Copy the formula I have in F21 down as far as you need. Apply the Conditional Formatting as shown. If this is what you want but need more help with how to implement it, post back.

Excel Workbook
CDEF
19DateTimeMin.No. of times
20Apr-08
21Wed - 09-Apr-20082:42 & 2:494 & 232
22Thu - 10-Apr-20083:2151
23Fri - 11-Apr-200810:27, 7:24 p.m., 7:39 & 7:401, 8, 1 & 124
24Tue - 15-Apr-200810:26, 10:31, 10:32, 11:26 & 11:306, 2, 4, 4, 25
Colour Cells
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F211. / Cell Value greater than or equal to3Abc
 
Upvote 0

shyam

Active Member
Joined
Jul 18, 2005
Messages
302
Dear Mr. Peter,

Your reply work fine, say nearly 90 %, but in case there is no data in column D and E, then in column F it should reflect 0, but is giving the result as 1.

Would appreciate if you could revert on that..

Tks a lot..

Shyam
 
Upvote 0

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
59,294
Office Version
  1. 365
Platform
  1. Windows
Edit: Note edited formula

Change the formula to
Code:
=(E21<>"")+LEN(E21)-LEN(SUBSTITUTE(SUBSTITUTE(E21,"&",""),",",""))
 
Last edited:
Upvote 0

doofusboy

Well-known Member
Joined
Oct 14, 2003
Messages
1,325
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 6 And Target.Value > 3 Then
        Target.Interior.Color = vbRed
    End If
End Sub
 
Upvote 0

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
59,294
Office Version
  1. 365
Platform
  1. Windows
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 6 And Target.Value > 3 Then
        Target.Interior.Color = vbRed
    End If
End Sub
That's basically trying to do in "longhand" what the Excel built-in Conditional Format feature does. However, this code will fail in two circumstances that I can think of...

1) The OP, as I understand it, wants a formula in column F. The Worksheet_Change event is not triggered by formula result cahnges.

2) Even if column F was being entered manually, it will not cope if more than one cell in column 6 is changed at the same time. eg select F20:F22, type 4 and confirm with Ctrl+Enter to enter all 3 cell at once. Selecting multiple cells and pressing Delete would be another case.
 
Upvote 0

shyam

Active Member
Joined
Jul 18, 2005
Messages
302
Dear Mr. Peter,

Thanks for your help.. It works fine now... Just to confirm with you, if instead of colouring the cell, can the result be shown within a circle in that cell in any way... i.e. the cell should be automatically circled if the result goes above 3.

Once again many thanks.

Rgds
Shyam
 
Upvote 0

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,283
...if instead of colouring the cell, can the result be shown within a circle in that cell in any way... i.e. the cell should be automatically circled if the result goes above 3.
Yes this is possible.

Three important points:

Important item #1, the below code assumes you accurately protrayed your data's layout, especially, that the range you care about for numbers greater than 3 is from F21 to F of the last used row.

Important item #2, the below code also assumes the cells in range F21 to F [whatever] contain formulas.

Important item #3, be sure you install the below code by right clicking on the sheet where all this fun stuff is going on, then left click on View Code, and paste the below code into the large white area that is the worksheet module. Press Alt+Q to return to the worksheet.

To get the code to start working, calculate the sheet or enter some value in some cell that generates another cell's formula to recalculate, and you will see circles around cells in column F that have numbers in them greater than 3.

The code:


Code:
Private Sub Worksheet_Calculate()
Application.ScreenUpdating = False
Dim cell As Range, CircleRange As Range
Dim oldShape As Shape, newShape As Shape
Dim iCount%
iCount = 0
Set CircleRange = Range("F21:F" & Cells(Rows.count, 6).End(xlUp).Row)
 
For Each oldShape In ActiveSheet.Shapes
If oldShape.Name Like "GreaterThanThree_*" Then oldShape.Delete
Next
 
For Each cell In CircleRange
With cell
If .Value > 3 Then
Set newShape = ActiveSheet.Shapes.AddShape(msoShapeOval, .Left - 2, .Top - 2, .Width + 4, .Height + 4)
newShape.Fill.Visible = msoFalse
newShape.Line.ForeColor.SchemeColor = 10
newShape.Line.Weight = 1.25
iCount = iCount + 1
newShape.Name = "GreaterThanThree_" & iCount
End If
End With
Next cell
 
Set newShape = Nothing
Set CircleRange = Nothing
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,191,718
Messages
5,988,275
Members
440,146
Latest member
rgomes8

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
Top