vbnullstring not working
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

VbNullString - not working??

resolvedResolved · Medium Priority · Version 2003

replyReply Mon 22 Sep 2008, 16:02Delegate Richard said...

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.

For upcoming training course dates see: Pricing & availability

replyReply Fri 26 Sep 2008, 11:32Trainer Laura said...

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

 

Please browse our web site to find out more about
excel-training-advanced courses and other Microsoft training courses.

Excel tip:

Hide columns in an Excel 2010 Worksheet

If you don’t want part of the Excel worksheet to be visible or when you don’t want certain data to appear in print outs, then a simple solution is to temporarily hide a column or multiple columns.

Hiding a single column:

1)Right click on the column header of the column you want to hide (this is the grey bar along the top edge of the worksheet)
2)Choose Hide from the menu
3)This column will now be hidden from view

Hide more than one column:

1)In the column header drag select to highlight the columns you want hidden
2)Right click and choose Hide from the menu

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard