View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ryan H Ryan H is offline
external usenet poster
 
Posts: 489
Default delete blank rows from other tab

You will have to put this code in a standard module. Then you can put a
command button on Sheet B and call this code. I assumed your Sheet A is
named "A", if not then you will have to change the code to the correct sheet
name.

Note: This macro may run slow if you have a huge amount of data on the
worksheet. If so we will need to make this code faster by doing a Sort first
or setting the criteria to one column.

Hope this helps! If so, let me know, click "YES" below.

Option Explicit

Sub DeleteBlankRows()

Dim lngLastRow As Long
Dim lngLastColumn As Long
Dim rw As Long
Dim col As Long

' this will help speed up the macro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

With Sheets("A")

' get last row and column of used range
lngLastRow = .UsedRange.Rows.Count
lngLastColumn = .UsedRange.Columns.Count

' scan each row of used range
For rw = lngLastRow To 1 Step -1

' test each cell in row if empty
col = 1
Do While IsEmpty(.Cells(rw, col)) And col <= lngLastColumn
col = col + 1
Loop

' if all cells in rw are empty then delete row
If col lngLastColumn Then .Rows(rw).Delete Shift:=xlUp
Next rw
End With

' return app settings
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub


--
Cheers,
Ryan


"Mayte" wrote:

hi,
anybody know a coed to delte the blank rows (row is all blank) if i'm in
other sheet. let's say i'm on sheet B and want to run a macro from sheet B to
delete blank rows from sheet A, any ideas ...??

cheers,
mayte