仅当单元格为空时,将单元格内容从一列复制到另一列

我试图将列H中的内容复制到列C只有当列H中的单元格是空的。

如果H是空的,我想离开列C中的文本

这里是我的,它复制H的内容,但是如果H是空的,它也清空C列。

Sub Button1_Click() Dim lngRow As Long Dim BotRow As Long Cells(Rows.Count, "H").Select Selection.End(xlUp).Select BotRow = Selection.Row For lngRow = 1 To BotRow If Not IsEmpty(Cells(lngRow, "H")) Then Cells(lngRow, "C") = Cells(lngRow, "H") End If Next End Sub 

vbNullString = "" ,所以只有有数据时才会将数据从H传输到C:

 Sub Button1_Click() Dim lngRow As Long Dim BotRow As Long BotRow = Cells(Rows.Count, "H").End(xlUp).Row For lngRow = 1 To BotRow If Cells(lngRow, "H") <> vbNullString Then Cells(lngRow, "C") = Cells(lngRow, "H") Else End If Next lngRow End Sub 
 Option Explicit Dim i As Long Dim n As Long Sub Copy() n = ActiveSheet.Cells(Rows.Count, "H").End(xlUp).Row For i = 1 To n If Cells(i, 8).Value <> vbNullString Then Cells(i, 3).Value = Cells(i, 1).Value End If Next i End Sub