Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Quick n' dirty code to delete rows?

Hello,

Can anyone write me a quick VBA example to delete an entire row if a
particular cell within that row is empty? I need excel to do this to multiple
rows until it gets to the end of the data.

Anyone?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Quick n' dirty code to delete rows?

Sub Dirty()
Dim L As Long
For L = 200 To 1 Step -1
If Cells(L, 1).Formula = "" Then Rows(L).Delete
Next
End Sub

HTH. Best wishes Anyone

"simsjr" skrev i melding
...
Hello,

Can anyone write me a quick VBA example to delete an entire row if a
particular cell within that row is empty? I need excel to do this to

multiple
rows until it gets to the end of the data.

Anyone?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Quick n' dirty code to delete rows?

Public Sub DeleteRowOnCell()
''delete any row that has a blank in selected column
Set coltocheck = Application.InputBox(prompt:= _
"Select A Column", Type:=8)
coltocheck.SpecialCells(xlCellTypeBlanks).EntireRo w.Delete
End Sub


Gord Dibben Excel MVP



On Wed, 18 Aug 2004 15:15:01 -0700, simsjr
wrote:

Hello,

Can anyone write me a quick VBA example to delete an entire row if a
particular cell within that row is empty? I need excel to do this to multiple
rows until it gets to the end of the data.

Anyone?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Quick n' dirty code to delete rows?

Hi,

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Option Explicit
Sub TEST()

Dim RNG As Range

If TypeName(Selection) < "Range" Then GoTo e:
If Selection.Areas.Count 1 Then GoTo e:

LOOP_1:
On Error Resume Next
Set RNG = Application.InputBox(Prompt:="Select a Range", _
Default:=Selection.Address, Type:=8)
If Err.Number 0 Then GoTo e:
On Error GoTo 0

If RNG.Cells.Count = 1 Then
If Len(RNG) = 0 Then RNG.EntireRow.Delete
Else
RNG.Columns(1).SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
End If

e:

End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


--
Reagrds,
Soo Cheon Jheong
_ _
^ ^
~



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Quick n' dirty code to delete rows?

You can be more detailed that this, but it can get you
going in the right direction.

'Understand that you must determine how many columns are
necessary to check

Sub Delete_Rows ()

r = 1
'Check each Row
Do
If Not IsEmpty(Cells(r,c)) Then
'Check each column within that row
Do Until c = 7 'Checks until the 7th column
If IsEmpty(Cells(r,c + 1)) Then
Cells(r,c).EntireRow.Delete
Else
c = c + 1
End If
Loop
End If 'Set up for next row
c = 1
r = r + 1
Loop Until IsEmpty(Cells(r,c))
'Assumes that at least column A will not be missing data.
End Sub


---Original Message-----
Hello,

Can anyone write me a quick VBA example to delete an

entire row if a
particular cell within that row is empty? I need excel

to do this to multiple
rows until it gets to the end of the data.

Anyone?
.



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
VBA code to delete rows Secret Squirrel Excel Discussion (Misc queries) 3 January 21st 07 03:01 PM
Quick Macro question - How to delete two rows then skip one - and repeat David Smithz Excel Discussion (Misc queries) 3 March 3rd 06 02:58 PM
Is there a quick way to delete all duplicate rows in a column? Jellaby Excel Discussion (Misc queries) 3 May 16th 05 10:47 PM
code to delete rows ianalexh Excel Discussion (Misc queries) 5 May 5th 05 10:46 AM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM


All times are GMT +1. The time now is 01:18 PM.

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

About Us

"It's about Microsoft Excel"