Looping through Merged cells in VBA

后端 未结 3 1621
孤街浪徒
孤街浪徒 2020-12-05 21:27

Is it possible to loop through merged cells in vba.

  • I have 6 merged cells in the range B4:B40
  • I need the values in these 6 cells 6 iterat
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 21:58

    Here is a first stab to your issue:

    Option Explicit
    
    Sub loopOverCells()
        Dim rCell As Range
        Dim i As Integer
    
        Set rCell = [B1]
        For i = 1 To 6
            Debug.Print rCell.Address
            Set rCell = rCell.Offset(1, 0)    ' Jump 1 row down to the next cell
        Next i
    End Sub
    

提交回复
热议问题