Find and Delete Rows with Empty Cells in Column A (VBA)

Hollando

Board Regular
Joined
Sep 13, 2012
Messages
55
Hello all,I'm trying to write a VBA code that will allow me to reference column A, then find the all cells that have no data inputted. After this I want to delete said row(s). The issue that I am running into is because the data that I am using has been copied from another sheet referred to as FORMULAS where I have several formulas (IF and Vlookup) in order to get the necessary information from three sheets into 1. The Vlookup reference is up to Row 10,000. Of course when pasting this into my RESULT tab I can not long perform a Ctlr + Down Arrow shortcut to find that last cell with Data as it will automatically find Cell A10000. There are a few standard formats that I apply once the data has been copied into the RESULT tabI cannot use a find and replace function because there will be cells in columns O through AH that will not return a value due to missing data in one of the three sheets.

The code I currently am using is:

Sub Paste_Values_Format_Gtin_Out_Of_Store_Date()
' Paste_Values_Format_Gtin_Out_Of_Store_Date Macro
' This Macro copys all data from the FORMULAS tab and pastes it into the RESULT tab
Sheets("FORMULAS").Select
Range("A3").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("RESULT").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

' This portion of the Macro Selects columns G and H then removes blank characters. Then Autofits the columns
Columns("G:H").Select
Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Columns("G:H").EntireColumn.AutoFit

Application.CutCopyMode = False
Selection.NumberFormat = "0"

'This portion of the Macro formats column P with the appropriate date format then selects cell A1
Columns("P:P").Select
Selection.NumberFormat = "m/d/yyyy"
Range("A1").Select

'This portion of the Macro resets the select in the Formulas tab
Sheets("FORMULAS").Select
Range("A3").Select

'This portion of the Macro returns to RESULT sheet
Sheets("RESULT").Select
End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
to eliminate rows Rows with Empty Cells in Column A
Code:
Sub delrows()
Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
 
Upvote 0
to eliminate rows Rows with Empty Cells in Column A
Code:
Sub delrows()
Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub

Thanks patel45! This worked great, however, there was one extra point I had to add in so that it would recognize the cells as truly blank.

So here's what I did

Code:
' Find and Replace Blanks with True Empty Cells within the RESULT tab
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Replace What:="", Replacement:="xxxxxxx", LookAt:=xlWhole, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Selection.Replace What:="xxxxxxx", Replacement:="", LookAt:=xlWhole, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
 
Upvote 0

Forum statistics

Threads
1,215,884
Messages
6,127,563
Members
449,385
Latest member
KMGLarson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top