将非空白单元格从范围复制到范围 [英] Copy Non Blank Cells From Range to Range

查看:121
本文介绍了将非空白单元格从范围复制到范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道您是否可以帮助我:

I wonder if you can help me with this:

范围B11:B251& C11:C251可能有也可能没有一些值。
我想要能够从单元格范围M11中复制非空白单元格:M251& N11:N251〜B11:B251& C11:C251,所以如果在M& N范围内有任何值,它们应该覆盖B& C中相同行中的值,但是如果在M& N范围内有空值,则不应该复制它们并且保留已经存在的值或不在B& C。
我清楚了吗? ; - )

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 M11:M251 & N11:N251 to B11:B251 & C11:C251, so if there are any values in M&N ranges they should overwrite values in the same rows in B&C but if there are blank values in M&N ranges they should not be copied and leave the values already present (or not) in B&C. Was I clear? ;-)

感谢任何回复!

推荐答案

Sub Main()
    Dim i As Long
    For i = 11 To 251
        If Not IsEmpty(Range("M" & i)) Then _
            Range("B" & i) = Range("M" & i)
        If Not IsEmpty(Range("N" & i)) Then _
            Range("C" & i) = Range("N" & i)
    Next i
End Sub

此代码将只将非空值从M& N列复制到B& C

this code will only copy non empty values from M&N columns to B&C

这篇关于将非空白单元格从范围复制到范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆