View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
DukeDevil DukeDevil is offline
external usenet poster
 
Posts: 8
Default Automatically Removing Rows where Cells A:R are Blank

Nevermind. I got the code to work for the ENTIRE row....Now I need it
to work only if cells A thru R in the row are blank. Any ideas?

Private Sub Worksheet_Change(ByVal Target As Range)

Dim SH As Worksheet
Dim col As Range
Dim rw As Range


Set SH = ActiveSheet


For Each col In SH.UsedRange.Columns
col.Hidden = Application.CountA(col) = 0
Next col


For Each rw In SH.UsedRange.Rows
rw.Hidden = Application.CountA(rw) = 0
Next rw
End Sub





Thulasiram wrote:
Hello,

I think this code that I got from this group should help you.

Private Sub CommandButton1_Click()
Dim SH As Worksheet
Dim col As Range
Dim rw As Range

Set SH = ActiveSheet

For Each col In SH.UsedRange.Columns
col.Hidden = Application.CountA(col) = 0
Next col

For Each rw In SH.UsedRange.Rows
rw.Hidden = Application.CountA(rw) = 0
Next rw
End Sub

hope this answers ur question. the above code hides the empty rows and
columns.

ALL CREDIT GOES TO THE PERSON WHO ACTAULLY HELPED ME IN SIMILAR
SITUATION AS URS.

Thulasiram.


DukeDevil wrote:
Hello,

I have a whole bunch of data that I keep mooving between sheets.
Sometimes I forget to delete the row once I have moved it. Is there any
sort of VBA code that I can write that recognizes when cells A to R are
BLANK and then automatically deletes the row? Please let me know.

Thank you.