VBA code takes long to excute

asher_nk

New Member
Joined
May 8, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am very new to VBA. I would like my code add a comment box to the active cell based on the text in the active cell. As the user inputs code it should add a comment. However when users move down the sheet and populate the rows it seems that the code takes longer to execute. Any help would be much appreciated.

Thanks.
 
Hi Michael,

I think i have solved why my code takes too long to run. Due to the VBA line regarding auto sizing. Everytime the code runs its resizes all the comment boxes.

VBA Code:
Dim xcomment As Comment
For Each xcomment In Application.ActiveSheet.Comments
xcomment.Shape.TextFrame.AutoSize = True
Next

End Sub

So I changed the code to this instead:
VBA Code:
ActiveCell.Comment.Shape.TextFrame.AutoSize = True

My apologies for not using the code tags still learning the lingo. Thanks for your help.
 
Upvote 0
Solution

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Did you try the modified code in Post #10
Rich (BB code):
My apologies for not using the code tags still learning the lingo.
No worries ...glad to help !!.. :cool: (y)
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,947
Members
448,534
Latest member
benefuexx

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