Macro to paste comment text in selected cells onto selected cells

exceluser2007

Active Member
Joined
Nov 21, 2007
Messages
365
Hi All,

I would like to understand how to do the following.

To create a macro that pastes the comments in all cells of a selected range into those corresponding cells.

The only caveat is, that if the comment contains the following text:

30/06/08: 3months 0% tax

I would like to exclude everything prior to ":" and trim all leading and trailing blanks, so that the required output would be

3months 0% tax

Could anyone please show how to write this code?

regards
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
try the below (which needs to be pasted into a vba Module). you'll need to have your commented cells selected before running the macro. you can also assign the below macro to a command button if you like as well:

Sub ReplaceComments()
For Each cmt In Selection
cmt.Value = cmt.Comment.Text
Next cmt
Selection.Replace What:="30/06/08: 3months 0% tax", Replacement:= _
"3months 0% tax", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False _
, SearchFormat:=False, ReplaceFormat:=False
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,991
Members
449,094
Latest member
masterms

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