[英]Excel VBA - Copy Cell Value, if empty, to another Cell in the same row
I am a complete new starter to VBAs and would require your help, my data looks like this: 我是VBA的全新入门者,需要您的帮助,我的数据如下所示:
. 。 ABCD
A B C D
1 tttt 1 tttt
2 tttt 2 tttt
3 ..... t 3 ..... t
4 tttt 4 tttt
5 tttt 5 tttt
6 ..... t 6 ..... t
7 tttt 7 tttt
The Macro should check, whether there is some information in Column A:A and if it is empty it should delete the value in the same row in column D. 宏应检查A:A列中是否有某些信息,如果为空,则应删除D列同一行中的值。
I hope that you can help me. 我希望你能帮助我。
Thanks in advance. 提前致谢。
Kind regards 亲切的问候
As per my understanding on your question, try the below code. 根据我对您问题的理解,请尝试以下代码。
Dim i As Integer
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To lastrow
If Range("A" & i) = "" Then
Range("D" & i).ClearContents
End If
Next i
您实际上不需要循环和一个内衬:
Range("A1", Cells(Rows.Count, "A").End(xlUp)).SpecialCells(xlCellTypeBlanks).Offset(, 3).ClearContents
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.