ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   delete empty rows in workbook (https://www.excelbanter.com/excel-worksheet-functions/104219-delete-empty-rows-workbook.html)

TooN

delete empty rows in workbook
 
Hi...

Ive got a problem with clearing rows. I want tp clear all the data in a row
if a cel in clomn B is emptry. I want to do that for the entire workbook. The
workbook im working in has about hundred sheets. It will take me hours to
clear all the rows manually. So far i got this code:

Sub ClearRows()
Dim rng As Range
Dim rowcounter As Integer
Dim sheetcounter As Integer

sheetcounter = 0
Do Until sheetcounter = 100
Sheet(sheetcounter).Activate
On Error Resume Next
Set rng = Columns(2).SpecialCells(xlBlanks)
On Error GoTo 0
If Not rng Is Nothing Then
rng.EntireRow.ClearContents
End If
sheetcounter = sheetcounter + 1
Loop
End Sub

Can anyone please tell me what im doing wrong?? (using 2003)

Thanks

Ron de Bruin

delete empty rows in workbook
 
Hi

If they are blank use this example
http://www.rondebruin.nl/specialcells.htm

If this not working post back


--
Regards Ron de Bruin
http://www.rondebruin.nl



"TooN" wrote in message ...
Hi...

Ive got a problem with clearing rows. I want tp clear all the data in a row
if a cel in clomn B is emptry. I want to do that for the entire workbook. The
workbook im working in has about hundred sheets. It will take me hours to
clear all the rows manually. So far i got this code:

Sub ClearRows()
Dim rng As Range
Dim rowcounter As Integer
Dim sheetcounter As Integer

sheetcounter = 0
Do Until sheetcounter = 100
Sheet(sheetcounter).Activate
On Error Resume Next
Set rng = Columns(2).SpecialCells(xlBlanks)
On Error GoTo 0
If Not rng Is Nothing Then
rng.EntireRow.ClearContents
End If
sheetcounter = sheetcounter + 1
Loop
End Sub

Can anyone please tell me what im doing wrong?? (using 2003)

Thanks





All times are GMT +1. The time now is 10:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com