用vba写一个当E列不为空,F列为空,G列显示F列为空的代码
时间: 2023-03-27 17:01:47
浏览: 57
你好,以下是回答:
Sub CheckEmpty()
Dim l[ast]([http]([http](https://geek.csdn.net/educolumn/68f28ca3131d47699e5902c5d3d74d51?spm=1055.2569.3001.10083)s://geek.csdn.net/educolumn/68f28ca3131d47699e5902c5d3d74d51?spm=1055.2569.3001.10083)s://geek.csdn.net/educolumn/1d2c256574d93ae646d4473629b198e6?spm=1055.2569.3001.10083)Row As Long
l[ast](https://geek.csdn.net/educolumn/1d2c256574d93ae646d4473629b198e6?spm=1055.2569.3001.10083)Row = Cells(Rows.Count, "E").End(xlUp).Row
For i = 1 To l[ast](https://geek.csdn.net/educolumn/1d2c256574d93ae646d4473629b198e6?spm=1055.2569.3001.10083)Row
If Not IsEmpty(Cells(i, "E")) And IsEmpty(Cells(i, "F")) Then
Cells(i, "G").Value = "F列为空"
End If
Next i
End Sub
希望能对你有所帮助。
相关问题
写一段Vba代码,取b列前5个字放到f列
Sub CopyFirstFiveChars()
Dim i As Integer
For i = 1 To 5
Range("F" & i).Value = Left(Range("B" & i).Value, 5)
Next i
End Sub
生成一个vba,筛选G列,取消空白,点击筛选
下面是一个生成 VBA 代码的示例,请注意,此代码仅供参考,因为我不了解您的工作表的结构和要求,因此您可能需要对代码进行修改:
Sub FilterColumnG()
' 定义变量
Dim ws As Worksheet
Set ws = ActiveSheet
' 筛选 G 列,取消空白
ws.Range("G:G").AutoFilter Field:=1, Criteria1:="<>", Operator:=xlAnd
' 点击筛选
ws.Range("G:G").AutoFilter
End Sub
要使用