Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi, I need to find a way to delete wholly blank rows from a spreadsheet that
also includes blank cells. I tried F5special...radio button BlanksOK ctrl+- delete rows , but that also deletes rows that have data in them along with a blank cell! Is there an equally neat way of deleting rows that have no data in them at all, but leaving partial rows? |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Heather,
Here's a VB solution. Right click the sheet tab, view code and paste this in. Slect the range you want to delete blank rows in and run the code. Sub DeleteBlankRows() Dim i As Long Application.ScreenUpdating = False For x = selection.Rows.Count To 1 Step -1 If WorksheetFunction.CountA(selection.Rows(x)) = 0 Then selection.Rows(x).EntireRow.Delete End If Next Application.ScreenUpdating = True End Sub Mike "Heather" wrote: Hi, I need to find a way to delete wholly blank rows from a spreadsheet that also includes blank cells. I tried F5special...radio button BlanksOK ctrl+- delete rows , but that also deletes rows that have data in them along with a blank cell! Is there an equally neat way of deleting rows that have no data in them at all, but leaving partial rows? |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Heather
Work on a COPY of your data, just in case!!! You could use an extra column alongside your data. Enter 1, 2 in the first 2 rows of this columnselect the 2 cellsgrab the fill handle at bottom right of cell containing the number 2fill down as far as you data extends. Now, Sort the entire block (including your new column) by any column that must have data to be retained. All rows which have a blank in this position, will be sorted to the bottom of the list. Delete the block of rows at the bottom of the list, then sort again by the new column to get the data back into it's original order. Delete the added new column -- Regards Roger Govier "Heather" wrote in message ... Hi, I need to find a way to delete wholly blank rows from a spreadsheet that also includes blank cells. I tried F5special...radio button BlanksOK ctrl+- delete rows , but that also deletes rows that have data in them along with a blank cell! Is there an equally neat way of deleting rows that have no data in them at all, but leaving partial rows? |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
One way - hide rows with data and then delete visible rows.
This is quickest if you use the keyboard shortcuts 1. Select the whole datasheet (Ctrl+A twice) then press... Shift+Tab (selects last data cell) Ctrl + \ (Edit Goto Special Row Differences) Ctrl + 9 (Format Row Hide) 2. Select whole datasheet again then: Alt+; (Edit Goto Special Visible Cells) Ctrl - (Edit Delete) Now select the datasheet and unhide the rows. "Heather" wrote: Hi, I need to find a way to delete wholly blank rows from a spreadsheet that also includes blank cells. I tried F5special...radio button BlanksOK ctrl+- delete rows , but that also deletes rows that have data in them along with a blank cell! Is there an equally neat way of deleting rows that have no data in them at all, but leaving partial rows? |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
How about this?
Sub delblankrows() lr = Cells.Find("*", Range("A1"), , , xlByRows, xlPrevious).Row On Error Resume Next For i = lr To 2 Step -1 If Rows(i).Find("*") Is Nothing Then Rows(i).Delete Next i End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Heather" wrote in message ... Hi, I need to find a way to delete wholly blank rows from a spreadsheet that also includes blank cells. I tried F5special...radio button BlanksOK ctrl+- delete rows , but that also deletes rows that have data in them along with a blank cell! Is there an equally neat way of deleting rows that have no data in them at all, but leaving partial rows? |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
This always works well for me:
Sub DeleteBlankRows1() '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 "Heather" wrote: Hi, I need to find a way to delete wholly blank rows from a spreadsheet that also includes blank cells. I tried F5special...radio button BlanksOK ctrl+- delete rows , but that also deletes rows that have data in them along with a blank cell! Is there an equally neat way of deleting rows that have no data in them at all, but leaving partial rows? |
#7
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thank you for all your help, I tried all your solutions but the two that came
out top were Don and Lori. Don's code worked but took a bit of time, Lori's method was quick and I'm impressed by all the keyboard shortcuts! I recorded Lori's method and heres a copy of the code. It does have a cell reference in it, which I moved to Z10000 to cover all my likely requirements, maybe one of you experts can "generalise" it. Thanks again, Heather Sub HideDeleteReveal() ' ' HideDeleteReveal Macro ' Hides Rows with Data, Deletes Blank Rows, and Reveals Data ' ' Range("A1").Select Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select Range("A1:Z10000").Select Range("Z10000").Activate Selection.RowDifferences(ActiveCell).Select Selection.EntireRow.Hidden = True Range("A1").Select Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select Selection.SpecialCells(xlCellTypeVisible).Select Selection.EntireRow.Delete Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select Selection.EntireRow.Hidden = False Range("A1").Select End Sub |
#8
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I meant to say A1 should be active initially, well done for following the
instructions. It's actually just three steps on the undo/redo dropdownlist and should be recordable without a fixed range. Here's a reduced version: Sub HideDeleteReveal() Cells.ColumnDifferences(Range("IV65536")).EntireRo w.Hidden = True Cells.SpecialCells(xlCellTypeVisible).Delete Shift:=xlUp Cells.EntireRow.Hidden = False End Sub "Heather" wrote: Thank you for all your help, I tried all your solutions but the two that came out top were Don and Lori. Don's code worked but took a bit of time, Lori's method was quick and I'm impressed by all the keyboard shortcuts! I recorded Lori's method and heres a copy of the code. It does have a cell reference in it, which I moved to Z10000 to cover all my likely requirements, maybe one of you experts can "generalise" it. Thanks again, Heather Sub HideDeleteReveal() ' ' HideDeleteReveal Macro ' Hides Rows with Data, Deletes Blank Rows, and Reveals Data ' ' Range("A1").Select Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select Range("A1:Z10000").Select Range("Z10000").Activate Selection.RowDifferences(ActiveCell).Select Selection.EntireRow.Hidden = True Range("A1").Select Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select Selection.SpecialCells(xlCellTypeVisible).Select Selection.EntireRow.Delete Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select Selection.EntireRow.Hidden = False Range("A1").Select End Sub |
#10
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Perfect - this code did exactly what I needed it for! Thanks!
"Lori" wrote: I meant to say A1 should be active initially, well done for following the instructions. It's actually just three steps on the undo/redo dropdownlist and should be recordable without a fixed range. Here's a reduced version: Sub HideDeleteReveal() Cells.ColumnDifferences(Range("IV65536")).EntireRo w.Hidden = True Cells.SpecialCells(xlCellTypeVisible).Delete Shift:=xlUp Cells.EntireRow.Hidden = False End Sub "Heather" wrote: Thank you for all your help, I tried all your solutions but the two that came out top were Don and Lori. Don's code worked but took a bit of time, Lori's method was quick and I'm impressed by all the keyboard shortcuts! I recorded Lori's method and heres a copy of the code. It does have a cell reference in it, which I moved to Z10000 to cover all my likely requirements, maybe one of you experts can "generalise" it. Thanks again, Heather Sub HideDeleteReveal() ' ' HideDeleteReveal Macro ' Hides Rows with Data, Deletes Blank Rows, and Reveals Data ' ' Range("A1").Select Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select Range("A1:Z10000").Select Range("Z10000").Activate Selection.RowDifferences(ActiveCell).Select Selection.EntireRow.Hidden = True Range("A1").Select Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select Selection.SpecialCells(xlCellTypeVisible).Select Selection.EntireRow.Delete Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select Selection.EntireRow.Hidden = False Range("A1").Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I delete blank rows (rows alternate data, blank, data, etc | Excel Discussion (Misc queries) | |||
Delete all blank rows... | Excel Discussion (Misc queries) | |||
To delete rows when more than one cell is blank | Excel Worksheet Functions | |||
delete blank rows | Excel Discussion (Misc queries) | |||
How to delete blank rows | Excel Discussion (Misc queries) |