#1   Report Post  
Posted to microsoft.public.excel.misc
CC CC is offline
external usenet poster
 
Posts: 91
Default DELETE ROW IF


Hello

I have this code to delete rows blank in columns at my choice
but I need also include another choice

"delete all rows if rows in X column are blank OR have a certain word (also
at my choice "


Is it possible ???
Thank you
cc
Sub DeleteEmptyRowsMain()
Dim myColm As Range
Dim LastCell As Range
Set myColm = Application.InputBox("Choose Start of column to clear",
Type:=8)
Set LastCell = Cells.Find("*", , , , , xlPrevious)
On Error Resume Next
If Not myColm Is Nothing Then
Range(myColm, Cells(LastCell.Row,
myColm.Column)).SpecialCells(xlCellTypeBlanks).Ent ireRow.Delete
Else
MsgBox "No Range Selected", vbOKOnly, "Error"
End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 267
Default DELETE ROW IF

I would consider creating a user form with two text boxes one to enter the
column as per your current sub the second for your text.
give it two command buttons "ok" and "cancel"
then put your nice little sub under command button (ok) click, put same sub
in twice once following if userform1.textbox1.value <""then
and userform1.textbox2.value <""then
substituting your column criteria for textbox1.value and find criteria for
textbox2.value.

"CC" wrote:


Hello

I have this code to delete rows blank in columns at my choice
but I need also include another choice

"delete all rows if rows in X column are blank OR have a certain word (also
at my choice "


Is it possible ???
Thank you
cc
Sub DeleteEmptyRowsMain()
Dim myColm As Range
Dim LastCell As Range
Set myColm = Application.InputBox("Choose Start of column to clear",
Type:=8)
Set LastCell = Cells.Find("*", , , , , xlPrevious)
On Error Resume Next
If Not myColm Is Nothing Then
Range(myColm, Cells(LastCell.Row,
myColm.Column)).SpecialCells(xlCellTypeBlanks).Ent ireRow.Delete
Else
MsgBox "No Range Selected", vbOKOnly, "Error"
End If

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default DELETE ROW IF

Try the below

Sub DeleteEmptyRowsMain()
Dim myColm As Range, lngRow As Long, lngEndRow As Long

Set myColm = Application.InputBox( _
"Choose Start of column to clear", Type:=8)

If Not myColm Is Nothing Then
lngEndRow = Cells.Find("*", SearchDirection:=xlPrevious).Row
For lngRow = lngEndRow To (myColm.Row + 1) Step -1
If Cells(lngRow, myColm.Column) = "" Or _
Cells(lngRow, myColm.Column) = "jacob" Then Rows(lngRow).Delete
Next
Else
MsgBox "No Range Selected", vbOKOnly, "Error"
End If

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"CC" wrote:


Hello

I have this code to delete rows blank in columns at my choice
but I need also include another choice

"delete all rows if rows in X column are blank OR have a certain word (also
at my choice "


Is it possible ???
Thank you
cc
Sub DeleteEmptyRowsMain()
Dim myColm As Range
Dim LastCell As Range
Set myColm = Application.InputBox("Choose Start of column to clear",
Type:=8)
Set LastCell = Cells.Find("*", , , , , xlPrevious)
On Error Resume Next
If Not myColm Is Nothing Then
Range(myColm, Cells(LastCell.Row,
myColm.Column)).SpecialCells(xlCellTypeBlanks).Ent ireRow.Delete
Else
MsgBox "No Range Selected", vbOKOnly, "Error"
End If

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.misc
CC CC is offline
external usenet poster
 
Posts: 91
Default DELETE ROW IF

I like Your sugestion but is to much for me .
How can I include your sugestion in "my" code ?
CC
"Atishoo" wrote:

I would consider creating a user form with two text boxes one to enter the
column as per your current sub the second for your text.
give it two command buttons "ok" and "cancel"
then put your nice little sub under command button (ok) click, put same sub
in twice once following if userform1.textbox1.value <""then
and userform1.textbox2.value <""then
substituting your column criteria for textbox1.value and find criteria for
textbox2.value.

"CC" wrote:


Hello

I have this code to delete rows blank in columns at my choice
but I need also include another choice

"delete all rows if rows in X column are blank OR have a certain word (also
at my choice "


Is it possible ???
Thank you
cc
Sub DeleteEmptyRowsMain()
Dim myColm As Range
Dim LastCell As Range
Set myColm = Application.InputBox("Choose Start of column to clear",
Type:=8)
Set LastCell = Cells.Find("*", , , , , xlPrevious)
On Error Resume Next
If Not myColm Is Nothing Then
Range(myColm, Cells(LastCell.Row,
myColm.Column)).SpecialCells(xlCellTypeBlanks).Ent ireRow.Delete
Else
MsgBox "No Range Selected", vbOKOnly, "Error"
End If

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.misc
CC CC is offline
external usenet poster
 
Posts: 91
Default DELETE ROW IF

Hi
doesn't work

cc

"Jacob Skaria" wrote:

Try the below

Sub DeleteEmptyRowsMain()
Dim myColm As Range, lngRow As Long, lngEndRow As Long

Set myColm = Application.InputBox( _
"Choose Start of column to clear", Type:=8)

If Not myColm Is Nothing Then
lngEndRow = Cells.Find("*", SearchDirection:=xlPrevious).Row
For lngRow = lngEndRow To (myColm.Row + 1) Step -1
If Cells(lngRow, myColm.Column) = "" Or _
Cells(lngRow, myColm.Column) = "jacob" Then Rows(lngRow).Delete
Next
Else
MsgBox "No Range Selected", vbOKOnly, "Error"
End If

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"CC" wrote:


Hello

I have this code to delete rows blank in columns at my choice
but I need also include another choice

"delete all rows if rows in X column are blank OR have a certain word (also
at my choice "


Is it possible ???
Thank you
cc
Sub DeleteEmptyRowsMain()
Dim myColm As Range
Dim LastCell As Range
Set myColm = Application.InputBox("Choose Start of column to clear",
Type:=8)
Set LastCell = Cells.Find("*", , , , , xlPrevious)
On Error Resume Next
If Not myColm Is Nothing Then
Range(myColm, Cells(LastCell.Row,
myColm.Column)).SpecialCells(xlCellTypeBlanks).Ent ireRow.Delete
Else
MsgBox "No Range Selected", vbOKOnly, "Error"
End If

End Sub



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default DELETE ROW IF

Do you mean a text string or a cell value? Try the below

Sub DeleteEmptyRowsMain()
Dim myColm As Range, lngRow As Long, lngEndRow As Long
Dim strFind As String

strFind = "cc"

Set myColm = Application.InputBox( _
"Choose Start of column to clear", Type:=8)

If Not myColm Is Nothing Then
lngEndRow = Cells.Find("*", SearchDirection:=xlPrevious).Row
For lngRow = lngEndRow To (myColm.Row + 1) Step -1
If Cells(lngRow, myColm.Column) = "" Or InStr(1, _
Cells(lngRow, myColm.Column), strFind, vbTextCompare) _
Then Rows(lngRow).Delete
Next
Else
MsgBox "No Range Selected", vbOKOnly, "Error"
End If

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"CC" wrote:

Hi
doesn't work

cc

"Jacob Skaria" wrote:

Try the below

Sub DeleteEmptyRowsMain()
Dim myColm As Range, lngRow As Long, lngEndRow As Long

Set myColm = Application.InputBox( _
"Choose Start of column to clear", Type:=8)

If Not myColm Is Nothing Then
lngEndRow = Cells.Find("*", SearchDirection:=xlPrevious).Row
For lngRow = lngEndRow To (myColm.Row + 1) Step -1
If Cells(lngRow, myColm.Column) = "" Or _
Cells(lngRow, myColm.Column) = "jacob" Then Rows(lngRow).Delete
Next
Else
MsgBox "No Range Selected", vbOKOnly, "Error"
End If

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"CC" wrote:


Hello

I have this code to delete rows blank in columns at my choice
but I need also include another choice

"delete all rows if rows in X column are blank OR have a certain word (also
at my choice "


Is it possible ???
Thank you
cc
Sub DeleteEmptyRowsMain()
Dim myColm As Range
Dim LastCell As Range
Set myColm = Application.InputBox("Choose Start of column to clear",
Type:=8)
Set LastCell = Cells.Find("*", , , , , xlPrevious)
On Error Resume Next
If Not myColm Is Nothing Then
Range(myColm, Cells(LastCell.Row,
myColm.Column)).SpecialCells(xlCellTypeBlanks).Ent ireRow.Delete
Else
MsgBox "No Range Selected", vbOKOnly, "Error"
End If

End Sub

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
delete the test values, but do not delete the formulas kathy Excel Discussion (Misc queries) 1 February 21st 07 07:03 PM
How can I delete a macro when the Delete button is not active? FCR Excel Worksheet Functions 0 March 9th 06 09:43 AM
How to Delete a Range in Closed Workbook (to Replace Delete Query) [email protected] Excel Discussion (Misc queries) 1 March 8th 06 10:10 AM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM


All times are GMT +1. The time now is 08:35 AM.

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"