Test for null - insert a row if isnull

G

Guest

Hi,

In a Macro (VBA) I am testing cell A6 for null, if isnull (""), I want to
insert a row. The problem is that it always inserts a row even when cell A6
has something in it? There are blank spaces at the from of the cell so I
trimmed it. Does anyone see something I'm doing wrong?


Sheets("Sheet1").Select
Range("A6").Select
If Trim(A6) = "" Then
Range("A4").Select
Selection.EntireRow.Insert
End If

Thanks in advance.

Bonnie
 
R

Ron de Bruin

Use it like this

This line is wrong
If Trim(A6) = "" Then


Sub Test()
Sheets("Sheet1").Select

If Trim(Range("A6")) = "" Then
Range("A4").EntireRow.Insert
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top