+ Reply to Thread
Results 1 to 7 of 7

Excel comment

Hybrid View

  1. #1
    Registered User
    Join Date
    02-08-2007
    Posts
    7

    Excel comment

    Hi all

    I am trying to find out if it is possible to do the following

    I have an excel sheet with comments in is it possible to print the comments with the cell content also. I know you can print comments at the end of the document but this does not include the figure/s in the cell

    Can anyone help
    Craig

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    This link should help

    http://www.contextures.com/xlcomment...ml#CopyToSheet

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    02-08-2007
    Posts
    7
    Cheers VBA Noob

    dont now how to use macros

    Is there an easier way?

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    It's very easy and quick

    Press Alt + F11
    Select Insert > Module

    Select the below code and paste in. Close Editor

    Then press

    ALT + F8 and select Showcomments macro to run


    Sub showcomments()
    'posted by Dave Peterson 2003-05-16 
        Application.ScreenUpdating = False
    
        Dim commrange As Range
        Dim mycell As Range
        Dim curwks As Worksheet
        Dim newwks As Worksheet
        Dim i As Long
    
        Set curwks = ActiveSheet
    
        On Error Resume Next
        Set commrange = curwks.Cells _
            .SpecialCells(xlCellTypeComments)
        On Error GoTo 0
    
        If commrange Is Nothing Then
           MsgBox "no comments found"
           Exit Sub
        End If
    
        Set newwks = Worksheets.Add
    
         newwks.Range("A1:D1").Value = _
             Array("Address", "Name", "Value", "Comment")
    
        i = 1
        For Each mycell In commrange
           With newwks
             i = i + 1
             On Error Resume Next
             .Cells(i, 1).Value = mycell.Address
             .Cells(i, 2).Value = mycell.Name.Name
             .Cells(i, 3).Value = mycell.Value
             .Cells(i, 4).Value = mycell.Comment.Text
           End With
        Next mycell
    
        Application.ScreenUpdating = True
    
    End Sub
    VBA Noob

  5. #5
    Registered User
    Join Date
    02-08-2007
    Posts
    7
    Great stuff

    Its a breeze

    another Q

    now im really getting into this how can I add alignment to the results sheet. I have already changed the cell names in the marco editor but would really like to align the cells and widen if poss

    Sorry to be a pain
    Craig

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try

    
    Sub showcomments()
    'posted by Dave Peterson 2003-05-16
        Application.ScreenUpdating = False
    
        Dim commrange As Range
        Dim mycell As Range
        Dim curwks As Worksheet
        Dim newwks As Worksheet
        Dim i As Long
    
        Set curwks = ActiveSheet
    
        On Error Resume Next
        Set commrange = curwks.Cells _
            .SpecialCells(xlCellTypeComments)
        On Error GoTo 0
    
        If commrange Is Nothing Then
           MsgBox "no comments found"
           Exit Sub
        End If
    
        Set newwks = Worksheets.Add
    
         newwks.Range("A1:D1").Value = _
             Array("Address", "Name", "Value", "Comment")
    
        i = 1
        For Each mycell In commrange
           With newwks
             i = i + 1
             On Error Resume Next
             .Cells(i, 1).Value = mycell.Address
             .Cells(i, 2).Value = mycell.Name.Name
             .Cells(i, 3).Value = mycell.Value
             .Cells(i, 4).Value = mycell.Comment.Text
           End With
        
        Next mycell
        Cells.Select
            With Selection
            .HorizontalAlignment = xlCenter ' or  xlRight or  xlLeft
            End With
         Cells.EntireColumn.AutoFit
         Range("A1").Select
        Application.ScreenUpdating = True
    
    End Sub
    VBA Noob

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1