#1   Report Post  
Posted to microsoft.public.excel.misc
nc nc is offline
external usenet poster
 
Posts: 119
Default Delete rows

Sub test()

Selection.Rows.EntireRow.Delete

End Sub

Can you help ammend the above code to stop the row (selection) being deleted
if the cell in column A has a number.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Delete rows

Hi,

Try this but note empty cells are treated as numeric. Post back and tell us
what should happen to empty cells

If Not (IsNumeric(Cells(ActiveCell.Row, 1))) Then
ActiveCell.EntireRow.Delete
End If

Mike

"nc" wrote:

Sub test()

Selection.Rows.EntireRow.Delete

End Sub

Can you help ammend the above code to stop the row (selection) being deleted
if the cell in column A has a number.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Delete rows

Option Explicit
sub test2()
dim myRng as range
dim myCell as range
dim DelRng as range

'just in case there's more than one area selected
set myrng = selection.areas(1).entirerow.columns(1) 'column A

for each mycell in myrng.cells
with mycell
if application.isnumber(.value) then
'skip it
else
if delrng is nothing then
set delrng = .cells
else
set delrng = union(delrng, .cells)
end if
end if
end with
next mycell

if delrng is nothing then
'nothing to delete
else
delrng.entirerow.delete
end if
end sub


nc wrote:

Sub test()

Selection.Rows.EntireRow.Delete

End Sub

Can you help ammend the above code to stop the row (selection) being deleted
if the cell in column A has a number.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Delete rows

Sub DeleteIfNOTnumber()
Columns(1).SpecialCells(xlCellTypeConstants, 2) _
.EntireRow.Delete 'Select
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"nc" wrote in message
...
Sub test()

Selection.Rows.EntireRow.Delete

End Sub

Can you help ammend the above code to stop the row (selection) being
deleted
if the cell in column A has a number.


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Delete rows

Do you mean

Sub Mac()
For lngRow = Selection.Rows.Count + _
Selection.Row - 1 To Selection.Row Step -1
If Not IsNumeric(Range("A" & lngRow).Text) Then
Rows(lngRow).Delete
End If
Next
End Sub

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


"nc" wrote:

Sub test()

Selection.Rows.EntireRow.Delete

End Sub

Can you help ammend the above code to stop the row (selection) being deleted
if the cell in column A has a number.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default Delete rows

And yet another variations

With Selection
If Not IsNumeric(Cells(.Row, 1)) Then .EntireRow.Delete
End With

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"nc" wrote:

Sub test()

Selection.Rows.EntireRow.Delete

End Sub

Can you help ammend the above code to stop the row (selection) being deleted
if the cell in column A has a number.

  #7   Report Post  
Posted to microsoft.public.excel.misc
nc nc is offline
external usenet poster
 
Posts: 119
Default Delete rows

Sorry, didn't work. Deleted any rows.

"Shane Devenshire" wrote:

And yet another variations

With Selection
If Not IsNumeric(Cells(.Row, 1)) Then .EntireRow.Delete
End With

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"nc" wrote:

Sub test()

Selection.Rows.EntireRow.Delete

End Sub

Can you help ammend the above code to stop the row (selection) being deleted
if the cell in column A has a number.

  #8   Report Post  
Posted to microsoft.public.excel.misc
nc nc is offline
external usenet poster
 
Posts: 119
Default Delete rows

sorry, please disregard my prior comment. your macro did not delete the row
with a blank cell in column A.

"nc" wrote:

Sorry, didn't work. Deleted any rows.

"Shane Devenshire" wrote:

And yet another variations

With Selection
If Not IsNumeric(Cells(.Row, 1)) Then .EntireRow.Delete
End With

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"nc" wrote:

Sub test()

Selection.Rows.EntireRow.Delete

End Sub

Can you help ammend the above code to stop the row (selection) being deleted
if the cell in column A has a number.

  #9   Report Post  
Posted to microsoft.public.excel.misc
nc nc is offline
external usenet poster
 
Posts: 119
Default Delete rows

I would like empty cell in column A to be deleted.

"Mike H" wrote:

Hi,

Try this but note empty cells are treated as numeric. Post back and tell us
what should happen to empty cells

If Not (IsNumeric(Cells(ActiveCell.Row, 1))) Then
ActiveCell.EntireRow.Delete
End If

Mike

"nc" wrote:

Sub test()

Selection.Rows.EntireRow.Delete

End Sub

Can you help ammend the above code to stop the row (selection) being deleted
if the cell in column A has a number.

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
How to Delete empty rows in excel in b/w rows with values Dennis Excel Worksheet Functions 3 August 28th 07 04:15 PM
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows Scott Excel Worksheet Functions 0 December 13th 06 01:25 AM
Q: delete rows JIM.H. Excel Discussion (Misc queries) 1 September 1st 05 02:57 PM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM
delete empty rows between rows with text Paulo Baptista Excel Discussion (Misc queries) 2 February 28th 05 03:41 PM


All times are GMT +1. The time now is 12:21 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"