I just downloaded a Micosoft CSV file from Google Contacts and I would like to modify it so that I can organize the contacts in my phone. I am going back to my "dumb" phone as part of an experiment of mine to simplify my life and the "dumb" phone doesn't have room for all the contacts in the file.

With that said, I think Google is, erm, stupid for listing almost everybody I've ever emailed in the life of my Gmail account and others I haven't (I suppose these come from email lists that I'm on). So the end result is that I have a huge list of contacts, but most of them I hardly even know and I don't have a phone number for. I don't send emails on my phone (and I obviously won't be sending them on my flip-phone either), so I don't need them.

So I've imported the CSV file into excel. Basically what I want to do is delete an entire row if, for that row, there is no data in the columns I'm concerned about


So let me simplify the problem a bit. Suppose First, middle and last name are in columns A,B, and C respectively. Then Mobile Phone number is in column D, home phone number is in column E, and email is in column F. For every contact in the list, I want to delete its row if it does not have data in column D or E or BOTH, but I couldn't care less if it has data in column F.

I've written the following macro, but it just seems to be deleting my entire spreadsheet, which it shouldn't be doing. I'm very new to Excel Macros and VBA, this is the first time I've ever done anything with them, so I'd appreciate some help.

Sub deleteBlankRows()
On Error Resume Next
End Sub

I think your idea is a good one, it's just not how VBA wants to work. I'd try it with a loop like this -

Sub deleterows()

Dim intcount As Integer
Dim introw As Integer

intcount = ActiveSheet.UsedRange.Rows.Count

For introw = intcount To 1 Step -1
    If Range("B" & introw) = "" Or Range("C" & introw) = "" Then
    Range("B" & introw).EntireRow.Delete
    End If


End Sub

On the if condition, just define whatever columns you want to check as Range("X" & introw) = "" separated by Or.

  • Thank you! I just modified it to suit my long list of columns and I changed Or to And because with Or it deleted my entire sheet again. And ensures that all of the columns of interest are blank before deleting while Or only cares if one of them are blank (All my rows had at least one blank column, so it deleted my entire sheet). But again, Thank you!, Thank you!, Thank you! – audiFanatic Feb 16 '14 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.