Mass copy of text with cell comments?

roscoe

Well-known Member
Joined
Jun 4, 2002
Messages
1,046
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I found this nice little line to do a large text copy from one workbook (or worksheet) to another:
Code:
rngTarget.Resize(rngSource.Rows.Count, rngSource.Columns.Count).Value = rngSource.Value

Now I've discovered that I need to copy the comments over as well. Is there a means to do this in one swell foop like the line above or must I do this line by line like this (stolen elsewhere :):
Code:
Function GetCommentText(myCell As Range) As String 
    On Error Resume Next 
    GetCommentText = myCell.Cells(1, 1).comment.Text 
End Function 

Option Explicit 
Sub Copy1() 
    Dim Cel As Range 
    With Worksheets("Sheet2") 
        .Range("A1:GA10000").ClearFormats 
        .Range("A1:GA10000").Clear 
    End With 
    Sheets("PRODUCTION STATUS").Range("B1:AV104").Copy Sheets("Sheet2").Range("A1") 
    For Each Cel In Range("a1:cV10000").SpecialCells(xlComments) 
        Cel.Value = "=getcommenttext(" & Cel.Address & ")" 
    Next 
End Sub

Thanks!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
How about using PasteSpecial...

Code:
rngSource.Copy

With rngTarget
    .PasteSpecial Paste:=xlPasteValues
    .PasteSpecial Paste:=xlPasteComments
End With

Application.CutCopyMode = False

???
 
Upvote 0
Copy/paste has a lot of downsides when one has a very large area, so I found the other technique to be much better.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,376
Members
449,080
Latest member
Armadillos

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