Hi guys,
I found the following vba code online which creates an additional sheet with all comments in a table:
Sub ShowCommentsAllSheets()
Dim commrange As Range
Dim rng As Range
Dim ws As Worksheet
Dim newWs As Worksheet
Set newWs = Application.Worksheets.Add
newWs.Range("A1").Resize(1, 4).Value = Array("Sheet", "Address", "Value", "Comment")
Application.ScreenUpdating = False
On Error Resume Next
For Each ws In Application.ActiveWorkbook.Worksheets
Set commrange = ws.Cells.SpecialCells(xlCellTypeComments)
If Not commrange Is Nothing Then
i = newWs.Cells(Rows.Count, 1).End(xlUp).Row
For Each rng In commrange
i = i + 1
newWs.Cells(i, 1).Resize(1, 4).Value = Array(ws.Name, rng.Address, rng.Value, rng.Comment.Text)
Next
End If
Set commrange = Nothing
Next
newWs.Cells.WrapText = False
Application.ScreenUpdating = True
End Sub
I would like to tweak the code in order that it:
Note:
I'm new to VBAs, it would be highly appreciated if someone could walk me through the code.
This is my first forum post, so please inform me if this post is not correctly formatted/in the correct place.
Kind regards,
Bram
I found the following vba code online which creates an additional sheet with all comments in a table:
Sub ShowCommentsAllSheets()
Dim commrange As Range
Dim rng As Range
Dim ws As Worksheet
Dim newWs As Worksheet
Set newWs = Application.Worksheets.Add
newWs.Range("A1").Resize(1, 4).Value = Array("Sheet", "Address", "Value", "Comment")
Application.ScreenUpdating = False
On Error Resume Next
For Each ws In Application.ActiveWorkbook.Worksheets
Set commrange = ws.Cells.SpecialCells(xlCellTypeComments)
If Not commrange Is Nothing Then
i = newWs.Cells(Rows.Count, 1).End(xlUp).Row
For Each rng In commrange
i = i + 1
newWs.Cells(i, 1).Resize(1, 4).Value = Array(ws.Name, rng.Address, rng.Value, rng.Comment.Text)
Next
End If
Set commrange = Nothing
Next
newWs.Cells.WrapText = False
Application.ScreenUpdating = True
End Sub
I would like to tweak the code in order that it:
- Adds a column before the sheet column that is 1.1 for the first question in a specific sheet 1.2 for the second question in the same sheet, 2.1 for the first question in the next sheet etcetera.
- That the value colum is directly linked to the relevant cell, so that is easy to follow the table to specific comments.
- Bullit point 2 implies that I wouldn't need the Address column anymore.
- Nice-to-have would be an easy filter which filters on the person which made the comment.
Note:
I'm new to VBAs, it would be highly appreciated if someone could walk me through the code.
This is my first forum post, so please inform me if this post is not correctly formatted/in the correct place.
Kind regards,
Bram