vbnullstring not working

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

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

VbNullString - not working??

resolvedResolved · Medium Priority · Version 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:

Quick Zooming in Excel with rollerball mouses

To zoom in and out of your page hold down the control key and roll the wheel up and down. This will zoom up and down 15% at a time.

View all Excel hints and tips


Server loaded in 0.08 secs.