Excel: How to check if a cell is empty with VBA?

Possible duplicate:
Using VBA to check if a cell is empty at the bottom

Via VBA, how can I check if a cell is empty from another with specific information?

For example:

If A: A = "special product" and B: B is zero, then

C1 = "special product"

Illustration of example

Also, how can I use a For Each loop in Range and how to return a value in another cell?

+58
vba excel-vba excel
Nov 13 '12 at 12:19
source share
3 answers

You can use the IsEmpty() function as follows:

 ... Set rRng = Sheet1.Range("A10") If IsEmpty(rRng.Value) Then ... 

You can also use the following:

 If ActiveCell.Value = vbNullString Then ... 

I am not a VBA programmer, so you will not mind ?!

hope this helps

+54
Nov 13 '12 at 12:40
source share

IsEmpty() will be the fastest way to test this.

IsNull() will look like a similar solution, but keep in mind that Null must be assigned to a cell; it is not essentially created in a cell.

Alternatively, you can check the cell for:

count()

counta()

Len(range("BCell").Value) = 0

+20
Nov 13 '12 at 12:52
source share

This site uses the isEmpty() method.

Edit: Content is captured from the site before the URL is invalid.

 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 

At the first stage, the data in the first column from Sheet1 will be sorted. In the second step, all rows with the same data will be deleted.

+10
Nov 13 '12 at 12:23
source share



All Articles