Help with Blank columns

happy_smiler1

New member
Joined
Aug 28, 2012
Messages
67
Reaction score
0
Points
0
Excel Version(s)
office 365
Hi All,

Does anyone know any type of vba to be able to look down columns and find all the blanks and delete them as some for some reason the excel formulas I have in place doesnt pick up the data I need unless I delete the blank columns.

I have attached a dummy data spreadsheet if anyone could help?

TIA
 

Attachments

  • Book1.xlsx
    9.5 KB · Views: 9
Code:
Option Explicit


Sub DelBlnk()
    Dim i As Long, lr As Long
    lr = Range("B" & Rows.Count).End(xlUp).Row
    For i = lr To 3 Step -1
        If Range("C" & i) = "" Then
            Range("C" & i).EntireRow.Delete
        End If
    Next i
End Sub
 
If im reading that code correctly, its saying if it finds a blank cell then its going to delete the row? what happens if if there is blank cell in column B5 but no data in column C5, i dont want to delete the row, just to delete the blank cells. Not sure if this is even possible.
 
When you say you want to delete the cell, please explain. Do you want the cell below to replace it? I don't know what you mean. If its blank, then there is nothing there. Please show an example in your file of what your file should look like if the cell is "deleted."
 
No worries, I have managed to do it a different way without any vba.

Thanks
 
I ended up just doing a macro and re-arranging my data as using the vba code deleted the entire row which isnt what I needed.

Much appreciated for the effort and response.
 
Back
Top