Possible Duplicate:
Using VBA to check if below cell is empty可能重复:使用VBA检查下面的单元格是否为空
As VBA via check if a cell is empty from another with specific information? example: If A:A = "product special" And B:B is null Then C1 = "product special" It's just an idea.
作为VBA,通过检查一个单元格是否为空,从另一个单元格中获取特定信息?例:如果A:A =“product special”,B:B为null,那么C1 =“product special”,这只是一个想法。
And how use For Each on the Range. And return the value in other cell?
以及如何在范围内使用。然后返回其他单元格中的值?
3 个解决方案
#1
45
You could use IsEmpty()
function like this:
可以使用IsEmpty()函数如下:
...
Set rRng = Sheet1.Range("A10")
If IsEmpty(rRng.Value) Then ...
you could also use following:
你也可以使用以下方法:
If ActiveCell.Value = vbNullString Then ...
I'm not a VBA programmer so you won't mind?!
我不是VBA程序员,你不会介意吧?!
hope it helps
希望它能帮助
#2
20
IsEmpty()
would be the quickest way to check for that.
IsEmpty()是检查它的最快方法。
IsNull()
would seem like a similar solution, but keep in mind Null has to be assigned to the cell; it's not inherently created in the cell.
IsNull()看起来类似于一个解决方案,但请记住,必须将Null分配给单元格;它不是天生在细胞中产生的。
Also, you can check the cell by:
此外,您还可以通过以下方式检查单元格:
count()
count()
counta()
counta()
Len(range("BCell").Value) = 0
Len(范围(“BCell”)value)= 0
#3
10
This site uses the method isEmpty()
.
这个站点使用isEmpty()方法。
Edit: content grabbed from site, before the url will going to be invalid.
编辑:在url无效之前,从站点抓取内容。
Worksheets("Sheet1").Range("A1").Sort _
key1:=Worksheets("Sheet1").Range("A1")
Set currentCell = Worksheets("Sheet1").Range("A1")
Do While Not IsEmpty(currentCell)
Set nextCell = currentCell.Offset(1, 0)
If nextCell.Value = currentCell.Value Then
currentCell.EntireRow.Delete
End If
Set currentCell = nextCell
Loop
In the first step the data in the first column from Sheet1 will be sort. In the second step, all rows with same data will be removed.
在第一步中,来自Sheet1的第一列中的数据将是排序的。在第二步中,将删除所有具有相同数据的行。
#1
45
You could use IsEmpty()
function like this:
可以使用IsEmpty()函数如下:
...
Set rRng = Sheet1.Range("A10")
If IsEmpty(rRng.Value) Then ...
you could also use following:
你也可以使用以下方法:
If ActiveCell.Value = vbNullString Then ...
I'm not a VBA programmer so you won't mind?!
我不是VBA程序员,你不会介意吧?!
hope it helps
希望它能帮助
#2
20
IsEmpty()
would be the quickest way to check for that.
IsEmpty()是检查它的最快方法。
IsNull()
would seem like a similar solution, but keep in mind Null has to be assigned to the cell; it's not inherently created in the cell.
IsNull()看起来类似于一个解决方案,但请记住,必须将Null分配给单元格;它不是天生在细胞中产生的。
Also, you can check the cell by:
此外,您还可以通过以下方式检查单元格:
count()
count()
counta()
counta()
Len(range("BCell").Value) = 0
Len(范围(“BCell”)value)= 0
#3
10
This site uses the method isEmpty()
.
这个站点使用isEmpty()方法。
Edit: content grabbed from site, before the url will going to be invalid.
编辑:在url无效之前,从站点抓取内容。
Worksheets("Sheet1").Range("A1").Sort _
key1:=Worksheets("Sheet1").Range("A1")
Set currentCell = Worksheets("Sheet1").Range("A1")
Do While Not IsEmpty(currentCell)
Set nextCell = currentCell.Offset(1, 0)
If nextCell.Value = currentCell.Value Then
currentCell.EntireRow.Delete
End If
Set currentCell = nextCell
Loop
In the first step the data in the first column from Sheet1 will be sort. In the second step, all rows with same data will be removed.
在第一步中,来自Sheet1的第一列中的数据将是排序的。在第二步中,将删除所有具有相同数据的行。