
'Hi, thanks for your advice. I have edited the codes alittle so that it can
'loop through all the worksheets, but it seems to have problems when i try to
'loop through more rows and columns. Can i do a check first whether the cells
'has a comment before copying the contents. Please help..Thanks
Sub Macro1()
Dim WksSummary As Worksheet
Dim tempstr1 As String 'variable for sheet 1
Dim tempstr2 As String 'variable for summary
Dim temprange1 As Integer 'cell no for sheet 1
Dim temprange2 As Integer 'cell no for summary'
Dim colrange1 As Integer
Dim colrange2 As Integer
Dim wks As Worksheet
Set WksSummary = Worksheets("Summary")
For Each wks In Worksheets
If Not wks.Name = "SUMMARY" Then
For colrange1 = 2 To 7 ' (2 to 7) ' looping through the columns b4 the rows
For temprange1 = 1 To 500 '(1 to 500) 'Looping through the values to copy
With wks.Cells(temprange1, colrange1)
If .Comment <> "" Then 'checking for comments
tempstr1 = .Value 'pulling out the value of cell from sheet 1
'If range("B" & temprange1).Comment <> "" Then
.Copy 'Copy Contents of the cell
End If
End With
For colrange2 = 5 To 12 ' (5 to 12)
For temprange2 = 1 To 1434 '(1 to 1434)'looping the no of times
With WksSummary.Cells(temprange2, colrange2)
tempstr2 = .Value
If tempstr2 = tempstr1 Then 'searching the cell to copy
'Paste the Comment Only
.PasteSpecial xlPasteComments
Exit For
End If
End With
Next temprange2
Next colrange2
Next temprange1
Next colrange1
End If
Next wks
End Sub