Ramesh Deo
Member
What methods to remove only entire blanks row not any blanks cell in a sheet if we have multiples data in a sheet, any keyboard shortcuts????
If you want to eliminate all blank rows in a data set
Sort it
The blanks will go to the top/Bottom and you can then delete them
Sub BlankRows()
'We turn off calculation and screenupdating to speed up the macro.
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
Sub AllBlankRows_Delete()
'Deletes the entire row within the selection if the ENTIRE row contains no data.
'We use Long in case they have over 32,767 rows selected.
Dim i As Long
'We turn off calculation and screenupdating to speed up the macro.
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
'We work backwards because we are deleting rows.
For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
Hi, Afarag, I think this method cann't be used for multiple Data.its a manual method.have u any method to select only entire blank rows through shortcuts,if any plz let me know!!!Hi Ramesh
you can select what rows or columns you that contain the blanks cell that you want to remove. then from Home ribbon choose Find & Select option, then click Go To Special... and from pop out window select Blanks
finally delete the selected data
thanks,
Thanks ChrisFunny thing, I just released a blog post about how to do this with VBA a few hours ago! You can check out the code snippet in my post Delete Blank Cells Or Entire Blank Rows Within A Range. Let me know if you have any questions about how to implement it but it should be pretty straight forward.
Thanks Chris
I didn't know about dis posting, but Its working n helpful for me & all.
let me know chris about dis Range("A1:A10") in macro, can we increase this range and till what range???
Yes you can expand the range to what ever length you wish.
Sub AllOpenWBs()
Dim wb As Workbook
Dim sht As Worksheet
Dim rng As Range
'Loop through all workbooks
For Each wb In Application.Workbooks
'Loop through all sheets in workbook
For Each sht In wb.Worksheets
Set rng = sht.Range("A1:A10").SpecialCells(xlCellTypeBlanks)
rng.Rows.Delete Shift:=xlShiftUp
Next sht
Next wb
End Sub
Yes, you could put it inside something like this:
Code:Sub AllOpenWBs() Dim wb As Workbook Dim sht As Worksheet Dim rng As Range 'Loop through all workbooks For Each wb In Application.Workbooks 'Loop through all sheets in workbook For Each sht In wb.Worksheets Set rng = sht.Range("A1:A10").SpecialCells(xlCellTypeBlanks) rng.Rows.Delete Shift:=xlShiftUp Next sht Next wb End Sub
Are you wanting to make it function as a personal macro and run it on the fly in whatever workbook you have open? This would definitely be possible if I am understanding you correctly.
Sub DeleteBlanks()
Dim rng As Range
Set rng = Activesheet.Range("A1:A10").SpecialCells(xlCellTypeBlanks)
rng.Rows.Delete Shift:=xlShiftUp
End Sub
thanks a lot 4 ur precious response!!!!I would code it like this then:
Code:Sub DeleteBlanks() Dim rng As Range Set rng = Activesheet.Range("A1:A10").SpecialCells(xlCellTypeBlanks) rng.Rows.Delete Shift:=xlShiftUp End Sub
thanks a lot 4 ur precious response!!!!