Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 363
Default Deleting blank rows which contain blank drop-down list boxes

Is it possible for a macro to do this?

I have seen many macros designed to remove blank rows in Excel but I have
many spreadsheets which, while the trailing rows appear to be blank, some
have list boxes which have not been used (appear blank) and I'd like to
remove those.

Thanks
Al
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Deleting blank rows which contain blank drop-down list boxes

Hi Al,

Do you mean data validation type drop downs?

If is data validation type drop downs:
"Some have list boxes which have not been used (appear blank)". Do you mean
that no selection has been made or the underlying list is now blank?

What version of xl are you using? Identifying the type of validation was
added to xl2007 so not sure if it could be done in previous versions.

--
Regards,

OssieMac


"Al" wrote:

Is it possible for a macro to do this?

I have seen many macros designed to remove blank rows in Excel but I have
many spreadsheets which, while the trailing rows appear to be blank, some
have list boxes which have not been used (appear blank) and I'd like to
remove those.

Thanks
Al

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Deleting blank rows which contain blank drop-down list boxes

If you want to delete empty rows which contain one or more cells with
dropdown list data validation in which no selection has been made, this macro
should do it:

Dim Rng As Range

Sub DelEmptyRowsWithDV()
Dim c As Range
Do While CountEmptyCellsWithDV 0
For Each c In Rng
If c.Validation.Type = 3 Then
With ActiveSheet
If Application.CountA(.Rows(c.Row)) = 0 Then
.Rows(c.Row).Delete
End If
End With
End If
Next c
Set Rng = Nothing
Loop
End Sub

Private Function CountEmptyCellsWithDV() As Long
Dim x As Long, m As Range
On Error GoTo CECwDVerr
Set Rng = ActiveCell.SpecialCells(xlCellTypeAllValidation)
x = 0
For Each m In Rng
If Len(m.Value) = 0 And m.Validation.Type = 3 Then
x = x + 1
End If
Next m
CountEmptyCellsWithDV = x
Exit Function
CECwDVerr:
CountEmptyCellsWithDV = -1
End Function

Hope this helps,

Hutch

"Al" wrote:

Is it possible for a macro to do this?

I have seen many macros designed to remove blank rows in Excel but I have
many spreadsheets which, while the trailing rows appear to be blank, some
have list boxes which have not been used (appear blank) and I'd like to
remove those.

Thanks
Al

  #4   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 363
Default Deleting blank rows which contain blank drop-down list boxes

Tom you are a true master of Excel VBA - thank-you very very much
This is exactly what I needed.
Al

"Tom Hutchins" wrote:

If you want to delete empty rows which contain one or more cells with
dropdown list data validation in which no selection has been made, this macro
should do it:

Dim Rng As Range

Sub DelEmptyRowsWithDV()
Dim c As Range
Do While CountEmptyCellsWithDV 0
For Each c In Rng
If c.Validation.Type = 3 Then
With ActiveSheet
If Application.CountA(.Rows(c.Row)) = 0 Then
.Rows(c.Row).Delete
End If
End With
End If
Next c
Set Rng = Nothing
Loop
End Sub

Private Function CountEmptyCellsWithDV() As Long
Dim x As Long, m As Range
On Error GoTo CECwDVerr
Set Rng = ActiveCell.SpecialCells(xlCellTypeAllValidation)
x = 0
For Each m In Rng
If Len(m.Value) = 0 And m.Validation.Type = 3 Then
x = x + 1
End If
Next m
CountEmptyCellsWithDV = x
Exit Function
CECwDVerr:
CountEmptyCellsWithDV = -1
End Function

Hope this helps,

Hutch

"Al" wrote:

Is it possible for a macro to do this?

I have seen many macros designed to remove blank rows in Excel but I have
many spreadsheets which, while the trailing rows appear to be blank, some
have list boxes which have not been used (appear blank) and I'd like to
remove those.

Thanks
Al

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting blank rows Rafeek Excel Discussion (Misc queries) 5 August 27th 11 03:20 PM
Ignore blank rows to populate custom drop down list column range vidtec Excel Programming 3 April 24th 06 07:27 PM
Deleting Blank Rows Reeni New Users to Excel 4 December 15th 05 01:56 AM
Deleting blank rows Alan M Excel Programming 3 January 26th 05 01:12 PM
Deleting Blank Rows LC[_5_] Excel Programming 1 June 3rd 04 06:55 PM


All times are GMT +1. The time now is 02:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"