Marching Ants Comment Border

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,595
Office Version
  1. 2021
Platform
  1. Windows
I would like to know if it is possible to have marching ant around a comments border ? If so, how can I set this up
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
No, it isn't as far as I know.
 
Upvote 0
If you mean a Cell comment then you could probably alternate the DashStyle Property of the comment and get a very close visual effect ... The following worked for me nicely:

Code in the ThisWorkbook Module ( Code assumes the comment is added to Cell Sheet1!A1 - amend Const as needed)

Code:
Option Explicit

Private WithEvents cmbrs As CommandBars

Private Const COMMENT_RANGE_ADDR As String = "Sheet1!A1"

Private Sub Workbook_Open()

    Set cmbrs = Application.CommandBars
    Call cmbrs_OnUpdate
    
End Sub

Private Sub cmbrs_OnUpdate()

    Static i As Long
    
    With Range(COMMENT_RANGE_ADDR).Comment.Shape.Line
        .DashStyle = (i Mod 2) + 4
        .Weight = 2
    End With
    
    i = IIf(i = 1, 0, i + 1)

End Sub

You could try playing with other dash styles.
 
Last edited:
Upvote 0
Thanks Jafaar. It works perfectly, when A double click on any cell
 
Upvote 0
Thanks Jafaar. It works perfectly, when A double click on any cell

Hi howard,

Do you mean that you need to double-click on any cell or otherwise it doen't work !? I am not sure I undestand what you mean -- If you can confirm that please .

The code as is, should work without the need for double-clicking cells or anything for that matter .
 
Last edited:
Upvote 0
Hi Jafaar


I have set up a dashed-line around the border of my comments. The marching ants scenario only works if I click on a cell. It is not automatic
 
Last edited:
Upvote 0
Hi Jafaar


I have set up a dashed-line around the border of my comments. The marching ants scenario only works if I click on a cell. It is not automatic
Strange! The code I posted works automatically for me without the need to click a cell or do anything.

Anyway, try this variation wich should now hopefully trigger the marching ants automatically :

Code:
Option Explicit

Private WithEvents cmbrs As CommandBars

Private Const COMMENT_RANGE_ADDR As String = "Sheet1!A1"

Private Sub Workbook_Open()

    Set cmbrs = Application.CommandBars
    Call cmbrs_OnUpdate

End Sub

Private Sub cmbrs_OnUpdate()

    Static i As Long

    With Range(COMMENT_RANGE_ADDR).Comment.Shape.Line
        .DashStyle = (i Mod 2) + 4
        .Weight = 2
    End With

    Application.CommandBars.FindControl(ID:=2040).Enabled = i
    
    i = IIf(i = 1, 0, i + 1)

End Sub
 
Upvote 0
Thanks for the amended code Jaafar

It works perfectly
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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