Leer los comentarios en celdas de Excel

Hola buen día JC, una consulta, mira ten go una bd un poco extensa de clientes de las cuales he hecho búsquedas en SAP y he puesto comentarios, pero no tuve a bien ponerlas en alguna columna si no que lo hice en comentarios. ¿Ahora qué requiero esta info comprenderás que es más complicado andar haciendo click derecho yh copiando la info? ¿Sabes la manera con una macro para poder extraerlos a otra hoja o libro y pegar esos comentarios en celdas?
Te agradezco como siempre
Saludos
ETC

1 respuesta

Respuesta
1
Aquí te dejo un pequeño ejemplo que tengo hace tiempo.
Sub ListComments()
Dim CommentCount As Integer
Dim cell As Range
Dim x As String
Dim CommentSheet As Worksheet
Dim OldSheets As Integer
Dim Row As Integer
' Salir si no hay comentarios
CommentCount = 0
For Each cell In ActiveSheet.UsedRange
On Error Resume Next
x = cell.Comment.Text
If Err = 0 Then CommentCount = CommentCount + 1
Next cell
If CommentCount = 0 Then
MsgBox "La hoja de trabajo activa no contiene ningún comentario.", vbInformation
Exit Sub
End If
' Crear nuevo libro de trabajo con una hoja
On Error GoTo 0
Set CommentSheet = ActiveSheet
OldSheets = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Workbooks.Add
Application.SheetsInNewWorkbook = OldSheets
ActiveWorkbook.Windows(1).Caption = "Comentarios para " & CommentSheet.Name & " en " & CommentSheet.Parent.Name
' Listar los comentarios
Row = 1
Cells(Row, 1) = "Dirección"
Cells(Row, 2) = "Contenidos"
Cells(Row, 3) = "Comentario"
Range(Cells(Row, 1), Cells(Row, 3)).Font.Bold = True
For Each cell In CommentSheet.UsedRange
On Error Resume Next
x = cell.Comment.Text
If Err = 0 Then
Row = Row + 1
Cells(Row, 1) = cell.Address(rowabsolute:=False, columnabsolute:=False)
Cells(Row, 2) = " " & cell.Formula
Cells(Row, 3) = cell.Comment.Text
End If
Next cell
Columns("B:B").EntireColumn.AutoFit
Columns("C:C").ColumnWidth = 34
Cells.EntireRow.AutoFit
End Sub
Espero te sirva.
Gracias no tengo duda que el code funciona, yo por mi parte ya lo resolví con la ayuda de este grandísimo foro, saludos JC y uevamente t estaré preguntando
Saludos

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas