View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
kennedy kennedy is offline
external usenet poster
 
Posts: 24
Default Deleting blank rows with formulas in them

Jacob,
Maybe I did something wrong. Changed the "SheetNames" to "GEO", which is one
of the worksheets that I have. Tried running the macro and returned an error:
Run-time error '1004':
Method 'Range' of object'_Global' failed.
When looking at the macro, the For Each cell In Range("GEO") is
highlighted in yellow

"Jacob Skaria" wrote:

You can try out the below macro. If you are new to macros..

--Set the Security level to low/medium in (Tools|Macro|Security).
--From workbook launch VBE using short-key Alt+F11.
--From menu 'Insert' a module and paste the below code.
--Get back to Workbook.
--Run macro from Tools|Macro|Run <selected macro()

Namedrange "SheetNames"..Change to suit

Sub DeleteRows()
Dim ws As Worksheet, cell As Range, lngRow As Long

For Each cell In Range("SheetNames")
Set ws = Sheets(cell.Text)

For lngRow = 24 To 8 Step -1
If WorksheetFunction.CountBlank(ws.Rows(lngRow)) = Columns.Count _
Then ws.Rows(lngRow).Delete
Next
Next
End Sub



--
Jacob (MVP - Excel)


"Kennedy" wrote:

I have a spreadsheet that takes data from one worksheet and moves it to
several worksheets, depending on a certain value. There are several
worksheets where the data has been moved, based on a macro and formula I
wrote.
There are several rows that will always be blank, however a formula appears
in those rows. Is there a way to create a macro that will look at all the
"named" sheets individually and find any rows from 8-300 that have a formula
in them, but do not contain actual data.
For instance, worksheet NEO has formulas that feed off another sheet from
row 8-300. However, only data appears in rows 8-125. Rows 126-300 are blank
but contain a formula. How can that e deleted.
Same thing with worksheet OEN, except data is present in rows 8-100, with
101-300 being blank but containint formulas.
Same with other worksheets.