LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Do not delete row with cell in Column B = 0

Hi,

I have a macro that allows a user to delete rows, which works great. However,
I want to prevent the user from deleting a footer row - (It contains the
legal notice and disclaimer.). The footer row can move up or down, depending
on how many rows have been added or removed above it. My thinking is to hide
a '0' in cell B of the footer row, by making the 0 the same color as the
background, and then letting the macro test for B(anyrow in a range)=0. If B
(anyrow in a range) = 0 and is the row the user wants to delete, show alert:
"Stop, you cannot delete the footer row!"

Here is my code so far:

' [I DON'T WANT THE FOOTER ROW DELETED THEREFORE IF B14=0 STOP THE DELETE.]
If Range("B14").Value "0" Then
'Run your code

' [THIS IS THE DELETE ROW CODE.]
Dim RowNdx As Long
RowNdx = Application.InputBox(prompt:="Enter the number of the row you want
to delete", Type:=1)
If RowNdx 0 And RowNdx <= Rows.Count Then
Rows(RowNdx).Delete
End If
'

' [B14 ALERT CONDITION NOT MET, THEREFORE SET ALERT]
Else: MsgBox "Stop! You may not delete the footer row."
Exit Sub
End If

The above works when the footer row moves up as other rows are deleted until
the footer row is in row 14. However, it does not work if the footer row is
in any other row and the user tries to delete it.

Help appreciated.

GBExcel

--
Message posted via http://www.officekb.com

 
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 numbers in each cell in same column Anna Huber Excel Worksheet Functions 7 June 11th 09 10:33 PM
Delete row with empty cell in column Gene Augustin Excel Discussion (Misc queries) 4 March 8th 09 08:03 AM
Delete Rows if any cell in Column H is blank but do not Delete Fir manfareed Excel Programming 4 September 28th 07 05:20 PM
delete a cell with a null value in column n Janis Excel Programming 3 July 18th 07 10:46 PM
How to delete the first word in every cell in a column Berit Excel Worksheet Functions 2 June 12th 07 12:38 PM


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