Copy Non Blank Cells From Range to Range

后端 未结 2 1051
感动是毒
感动是毒 2020-12-11 13:55

I wonder if you can help me with this:

Ranges B11:B251 & C11:C251 may or may not have some values. I want to be able to copy non blank cells from cell ranges M1

2条回答
  •  醉梦人生
    2020-12-11 14:23

    This piece of code should do the trick:

    Sub CopyRangeToRange()
        Dim CpyFrom As Range
        Dim Cell As Range
    
        Set CpyFrom = ActiveSheet.Range("M11:N251")
    
        For Each Cell In CpyFrom
            If Cell.Value <> vbNullString Then
                Cell.Offset(0, -11).Value = Cell.Value
            End If
        Next Cell
    End Sub
    

提交回复
热议问题