Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

vbnullstring not working

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » VbNullString - not working??

VbNullString - not working??

ResolvedVersion 2003

Richard has attended:
Excel VBA Intro Intermediate course

VbNullString - not working??

Hi there,

I have tried using the vba function vbNullString as below,

If Range(ActiveCell) = vbNullString Then
ActiveCell.EntireRow.delete

it scans through the data, but does not identify the cells as having no data within them and therefore it does not delete the row, I have also tried:

If ActiveCell.Value. = " " Then
ActiveCell.EntireRow.delete

Again, this doesnt seem to identify empty cells and doesnt delete the row.

The data originally came from a text file - is this linked to the problem?

Any advice or a better way to do it please?

Thanks for your help.

RE: vbNullString - not working??

Hi Richard

Welcome to the joys of finding empty cells, it can be tricky.

The cells could contain spaces which would fail on the above tests.

I would try

If Trim(Activecell.Value)=vbNullString Then Activecell.EntireRow.Delete


Remember to be careful that you only need to move down a row when you do not delete a row.

Let me know how you get on.

Laura GB

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Creating Quick Column Charts

Select the information you want to appear in the chart and press F11. This creates a new chart on a seperate worksheet.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.19 secs.