Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

VBA MERGE CELLS DURING PROCEDURE I WOULD LIKE TO HAVE CELLS H-L MERGE ON CURRENT

ID: 639923 • Letter: V

Question

VBA MERGE CELLS DURING PROCEDURE

I WOULD LIKE TO HAVE CELLS H-L MERGE ON CURRENT ROW AT STEP BELOW BUT CAN'T GET IT TO WORK

'COPY COMMENTS AND CELL NAME TO THE BOTTOM OF THE SHEET.

        Sub ShowComments()
        Application.ScreenUpdating = False

         Dim commrange As Range
         Dim mycell As Range
         Dim curwks 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

          curwks.Range("A270").Value = _
              Array("WORKSHEET NAME") 'Title for section

         i = 270 'row to start adding comments/name. if adding rows, be sure to change this
         For Each mycell In commrange
            With curwks
              i = i + 1
              On Error Resume Next
              .Cells(i, 7).Value = mycell.Name.Name 'adds cell name in column G
              .Cells(i, 8).Value = mycell.Comment.Text 'adds cell comments in column H
    I WOULD LIKE TO HAVE CELLS H-L MERGE ON CURRENT ROW AT THIS POINT, BUT CAN'T GET ANYTHING TO WORK- ANY IDEAS?
            End With

         Next mycell


    End Sub

Thanks !!

Explanation / Answer

Hi..

Hi,

Add this line at the appropriate point in your code.

.Cells(i, 8).Resize(, 5).MergeCells = True