2 easy ways to extract all comments in Excel to a sheet

While working in Excel, in some cases you may need to extract all the comments of cells to a sheet.

It is super time consuming if you extract many comments manually as there is no inbuilt option in Excel.

Here I will show to 2 ways to quickly get all comment text into Excel cell.

Using this method you can quickly get all the Excel comments in a sheet for the purpose of organizing , review and analysis.

Extract all Excel comments to a sheet using VBA

Below is the example table (in sheet2)  where some comments are present in different cells.

Extract comments in excel

Below is the output table after extracting all the comments of Excel worksheets.

Comment text column represents the comment text and also provides a link to that cell.

You can click comment text and quickly visit a cell with a comment.

Extract all comments present in Excel workbook

  • Below is the Excel VBA code for getting all the comments of a workbook.

Follow the below steps to implement the code

  • Press Alt+F11 or right-click on any sheet then click the View code option to view VBA IDE panel.
  • Create a new standard module in VBA IDE.

Creating Standard module in Excel VBA IDE

    Creating Standard module in Excel VBA IDE
  • Copy and paste the below code into the newly created module.
  • Now come to Excel and press F8 shortcut key to bring the Macro pane.
  • Select “exctractComments” from the Macro pane list then click on the Run button.

Note: Make sure to save the workbook as “.xlsm” (macro) or “.xlsb” (binary) format. 

Suggested Readings

Know 6 different ways to run VBA or Macro in Excel

How to insert and run VBA code in Excel?

How to make Microsoft Excel Add in?

Sub exctractComments()
  Dim ws As Worksheet
  Dim cmnt As Comment
  Dim cmntSht As Worksheet
  Dim cmntShtNm As String
  cmntShtNm = "AllComments"
  On Error Resume Next
  If Worksheets(cmntShtNm) Is Nothing Then
     Set cmntSht = Worksheets.Add
     cmntSht.Name = cmntShtNm
     With cmntSht
         .Range("A1").Value = "Sheet Name"
         .Range("B1").Value = "Cell Address"
         .Range("C1").Value = "Comment by"
         .Range("D1").Value = "Comment text"
         .Range("A1:D1").Font.Bold = True
     End With
  End If
   Set cmntSht = Worksheets(cmntShtNm)
  On Error GoTo 0
  Dim lrw As Long, txt As String, lnkAdd As String
  lrw = cmntSht.Range("B" & Rows.Count).End(xlUp).Row + 1
  For Each ws In Worksheets
    If ws.Comments.Count = 0 Then GoTo jmp
     For Each cmnt In ws.Comments
       cmntSht.Range("A" & lrw).Value = ws.Name
       cmntSht.Range("B" & lrw).Value = cmnt.Parent.Address
       cmntSht.Range("C" & lrw).Value = cmnt.Author
       txt = Replace(cmnt.Text, cmnt.Author & ":" & Chr(10), "")
       If txt = "" Then txt = "-"
       lnkAdd = "'" & ws.Name & "'!" & cmnt.Parent.Address
       cmntSht.Hyperlinks.Add Anchor:=cmntSht.Range("D" & lrw), _
     Address:="#" & lnkAdd, TextToDisplay:=txt
       lrw = lrw + 1
     Next cmnt
jmp:
  Next ws
   cmntSht.Activate
End Sub

Excel formula to get comment text

In the below image, you can see f_exctractComments formula is used to get comment text.

Syntax : f_exctractComments(cel As Range)

By default this formula is not there in Excel, it is build by using the VBA function or VBA UDF (User Defined Function)

Excel formula to extract comment

To implement the below VBA UDF or custom function follow the below steps.

  • Press ALT+F11 to bring VBA IDE.
  • Create a new standard module in VBA IDE.
  • Copy paste the below code into the newly created module.

Note: It is not necessary to always create a new module, you can also paste the code into an already existing or created standard module.

Function f_exctractComments(cel As Range) As String
  Dim cmntStr As String
  Dim auth As String
  On Error Resume Next
  cmntStr = cel.Comment.Text
  If Err.Number <> 0 Then
    f_exctractComments = ""
    Exit Function
  End If
   auth = cel.Comment.Author
   f_exctractComments = Replace(cmntStr, auth & ":" & Chr(10), "")
End Function

Download file – Extract comment in excel

Compare two columns in Excel to find matches and differences – 4 examples

Sometimes you may need to compare two or more Excel columns to find the matches and differences.

Here I have discussed various scenarios and respective methods to compare values in Excel columns.

Compare two columns in Excel row wise

In the below example scenario, you can see two columns are compared for matched values.

Simple If formula is used to find the row wise matched and not matched values between columns.

Cell C2 formula

=IF(A2=B2,”Matched”,”Not matched”)

compare two columns in Excel row wise

Compare two columns exact case wise in Excel

In this scenario you not only want to compare 2 columns by value but also by letter case also.

Same If formula can be used but with a little twist.

Cell C2 formula

=IF(EXACT(A2,B2),”Matched”,”Not matched”)

Here you can see in If function Exact function is used to check whether case is also same.

You can see “Papaya” and “Kiwi” example row , here spellings are same but case is different hence formula is outputting “Not matched”.

Compare two columns in Excel case wise

Compare two columns by highlighting matching rows in Excel

Here is a step by step way to highlight matching rows in Excel using conditional formatting.

1 – Select range and make sure 1st cell of the selected range is active.

2 – Press the ALT O D keys in series and click on New Rule.

Alternatively, click HOME tab > CONDITIONAL FORMATTING > New Rule 

Compare two columns in Excel by highlighting matched rows

3 – Now click on “Use a formula to determine which cells to format”

4 – Write formula rule =$A2=$B2. Putting $ sign before column is important.

5 – Click on OK button.

highlight matched rows in Excel

6 – Click on Fill tab. Select highlight color.

7 – Click on OK button and  in all upcoming pane click on OK button.

highlight matched rows in Excel using conditional formatting

In the below image, you can see matched rows between columns got highlighted.

Same method you can use to highlight not matched rows in Excel

This is how you can visually compare two columns in Excel.

compare two columns in Excel using Conditional format

Compare two or more columns of two tables in Excel

In the below image you can see two tables.

 I want to compare both the Supplier name and the respective amount side by side.

In comparison, I want to see missing values, matched values, and not matched values for a given record in the two tables. 

These two tables may present in different sheet or different workbooks, it doesn’t matter.

For simplicity in both tables rows are less and the column count is limited to 2 columns. 

But using this clean, simple approach you can compare many columns with many number of rows.

Also, you can compare more than tow tables using this approach.

Compare two or more columns of separate tables in Excel

Below is expected output of side by side column comparison.

compare two or more columns from different sheet in Excel

1 – First merge two table one below other to make a big table. 

Here you need identify each table records by their table source. In the below image column named “Table” created for this purpose.

compare two or more columns in Excel

2 – Now select this merged range with heading and create Pivot Table. Follow the below steps.

  • Select range then go to the Insert tab and click on Pivot table option.
  •  Select whether you want to create Pivot in existing or new worksheet.
  • Click OK button.

Note:- In the below image table is different. Image only represent steps to follow for making Pivot table in Excel. 

create pivot table in Excel

3 – Click on any cell of the pivot table region to bring “PivotTable Tools” tab.

4 – In PivotTable Tools click on Design. Then from Grand Totals drop down list click on “Off for Rows and Columns” option.

Do not show grand totals in Pivot table in Excel

5 – In Report Layout click on Show in Tabular Form and Repeat All Item Labels on by one.

Pivot table show in tabular form and repeat all items setting

6 – Arrange columns in their respective area as per the below image. Supplier is in the Rows area, table is in Columns, and Amount in the Values area.

As you can see we brought columns of two table (two list) side by side for comparison purposes.

compare two or more columns in Excel using pivot table

Additionally, you can add a formula column at the end to compare columns for missing, matched and not matched values.

Cell D3 formula 

=IF(B3=””,”Missing in T-1″,IF(C3=””,”Missing in T-2″,IF(B3=C3,”matched”,”not matched”)))

Note: Since suppliers will auto get sorted in ascending order you can also see whether mismatch is due to typo error or not. See 8th and 9th row of “Northern Supplies”.

compare 2 or more columns in Excel

I think using the Pivot table technique is one the best way to compare multiple columns in Excel to find matches and differences.

The below video shows different examples but has the same approach of column comparison in Excel.

https://youtu.be/uV7o4CG6j7A
Download file – compare two columns in excel

Share via
Copy link
Powered by Social Snap