Comments to move with cell in macro

nparsons75

Well-known Member
Joined
Sep 23, 2013
Messages
1,256
Office Version
  1. 2016
Hi,

I have a macro that copies and pastes cells from one column to the next to the right. This works fine but does not copy any comments that are attached to the cell, they remain in the original cell. Is there a way to ensure comments move with the cells within the macro?

My code is:

Code:
Sub Macro2()    Application.ScreenUpdating = False
    Sheets("Tracker").Select
    Range("B12:J61").Select
    ActiveWindow.SmallScroll Down:=-18
    Sheets("OUTPUT").Select
    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Sheets("Tracker").Select
    Range("K8:K61").Select
    Selection.Copy
    Sheets("OUTPUT").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Columns("A:A").EntireColumn.AutoFit
    Sheets("Tracker").Select
    ActiveWindow.SmallScroll Down:=-15
    Range("B12:J61").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveWindow.SmallScroll Down:=-15
    Range("C12").Select
    ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False, _
        IconFileName:=False
    Range("B12:B61").Select
    Selection.ClearContents
End Sub


Sub Macro3()






If Range("B11").Value = 0 Then
Range("B1").Value = result
    Application.ScreenUpdating = False
    Range("C12:K61").Select
    Selection.Copy
    Range("B12").Select
    ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False, _
        IconFileName:=False
    Range("K12:K61").Select
    Selection.ClearContents
    Sheets("OUTPUT").Select
    Range("A5:A54").Select
    Selection.Copy
    Sheets("Tracker").Select
    Range("K12").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("OUTPUT").Select
    Columns("A:A").Select
    Range("A31").Activate
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlToLeft
    Sheets("Tracker").Select


Else


MsgBox "NO UNDO AVAILABLE"




    End If
End Sub

Thanks,
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You just add in another selection.pastespecial command once the values are copied over, add this:-

Selection.PasteSpecial Paste:=xlPasteComments, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Hows that ?
 
Upvote 0
The good news is that it can be done....Thank you..

Im not sure where I would include it into the code? Would you know? Im not great with VBA, someone else created the code for me.

Thank you for your time.
 
Upvote 0
This is what I tried but failed:

Does it automatically copy the comments with selection.copy

Code:
Sub Macro2()    Application.ScreenUpdating = False
    Sheets("Tracker").Select
    Range("B12:J61").Select
    ActiveWindow.SmallScroll Down:=-18
    Sheets("OUTPUT").Select
    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Sheets("Tracker").Select
    Range("K8:K61").Select
    Selection.Copy
    Sheets("OUTPUT").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteComments, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
    Columns("A:A").EntireColumn.AutoFit
    Sheets("Tracker").Select
    ActiveWindow.SmallScroll Down:=-15
    Range("B12:J61").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveWindow.SmallScroll Down:=-15
    Range("C12").Select
    ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False, _
        IconFileName:=False
    Range("B12:B61").Select
    Selection.ClearContents
End Sub


Sub Macro3()






If Range("B11").Value = 0 Then
Range("B1").Value = result
    Application.ScreenUpdating = False
    Range("C12:K61").Select
    Selection.Copy
    Range("B12").Select
    ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False, _
        IconFileName:=False
    Range("K12:K61").Select
    Selection.ClearContents
    Sheets("OUTPUT").Select
    Range("A5:A54").Select
    Selection.Copy
    Sheets("Tracker").Select
    Range("K12").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteComments, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
    Sheets("OUTPUT").Select
    Columns("A:A").Select
    Range("A31").Activate
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlToLeft
    Sheets("Tracker").Select


Else


MsgBox "NO UNDO AVAILABLE"




    End If
End Sub
 
Upvote 0
Sorry for the delay in replying,

I needed a few more lines of code - have just stepped through your macro. The below works for me now, I think the entire code could be simplified / improved
if I could see exactly what was needed. Seems like too many lines for a simple task..

Sub Macro2()
Application.ScreenUpdating = False
Sheets("Tracker").Select
Range("B12:J61").Select
ActiveWindow.SmallScroll Down:=-18
Sheets("OUTPUT").Select
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Tracker").Select
Range("K8:K61").Select
Selection.Copy
Sheets("OUTPUT").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Columns("A:A").EntireColumn.AutoFit
Sheets("Tracker").Select
ActiveWindow.SmallScroll Down:=-15
Range("B12:J61").Select
Application.CutCopyMode = False
Selection.Copy
ActiveWindow.SmallScroll Down:=-15
Range("C12").Select
ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False, _
IconFileName:=False
Range("b13").CurrentRegion.Rows.Select
Selection.Copy
Range("c12").Select
Selection.PasteSpecial Paste:=xlPasteComments, Operation:=xlNone, _
SkipBlanks:=True, Transpose:=False
Range("B12:B61").Select
Selection.ClearContents
End Sub

Hope that helps?!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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