#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Delete Row

I want to be able to run a macro which will delete the row selected if column
A is blank. If it is not blank then message box "Unable to delete this row!"
I've looked through code already available but can't find anything that does
this.
Could someone please help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete Row

Hi Karen,

Try:

'=============
Public Sub Tester()
With ActiveCell.EntireRow
If IsEmpty(.Cells(1)) Then
.Delete
End If
End With
End Sub
'<<=============


---
Regards,
Norman



"Karen McKenzie" wrote in message
...
I want to be able to run a macro which will delete the row selected if
column
A is blank. If it is not blank then message box "Unable to delete this
row!"
I've looked through code already available but can't find anything that
does
this.
Could someone please help.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Delete Row

Hi
If Application.Worksheetfunctions.Counta(Range("A:A") ) = 0 then
Selection.EntireRow.Delete
Else
Msgbox "Unable to Delete this Row!"
End if

If your column A contains a formula which returns empty text "" then
that will also be counted, even though the cell looks empty, so just
be careful with that.
regards
Paul

On Apr 18, 9:36 am, Karen McKenzie
wrote:
I want to be able to run a macro which will delete the row selected if column
A is blank. If it is not blank then message box "Unable to delete this row!"
I've looked through code already available but can't find anything that does
this.
Could someone please help.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete Row

Hi Karen,

I forgot the MsgBox!

'=============
Public Sub Tester()
With ActiveCell.EntireRow
If IsEmpty(.Cells(1)) Then
.Delete
Else
MsgBox Prompt:="Unable to delete this row!"
End If
End With
End Sub
'<<=============


---
Regards,
Norman


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Delete Row

On Apr 18, 9:48 am, wrote:
Hi
If Application.Worksheetfunctions.Counta(Range("A:A") ) = 0 then
Selection.EntireRow.Delete
Else
Msgbox "Unable to Delete this Row!"
End if

If your column A contains a formula which returns empty text "" then
that will also be counted, even though the cell looks empty, so just
be careful with that.
regards
Paul

Hi
I read your problem slightly differently to Norman Jones, but his
interpretation is probably correct. My response assumes you want to
delete when ALL of column A is empty. His assumes you want to delete
when the cell in column A for that row is empty.
regardfs
Paul


On Apr 18, 9:36 am, Karen McKenzie



wrote:
I want to be able to run a macro which will delete the row selected if column
A is blank. If it is not blank then message box "Unable to delete this row!"
I've looked through code already available but can't find anything that does
this.
Could someone please help.- Hide quoted text -


- Show quoted text -





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Delete Row

works perfectly - Thanks!

"Norman Jones" wrote:

Hi Karen,

I forgot the MsgBox!

'=============
Public Sub Tester()
With ActiveCell.EntireRow
If IsEmpty(.Cells(1)) Then
.Delete
Else
MsgBox Prompt:="Unable to delete this row!"
End If
End With
End Sub
'<<=============


---
Regards,
Norman



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
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 1 June 22nd 05 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:20 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


All times are GMT +1. The time now is 06:07 PM.

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"