Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel Problem - Delete Row Macro

I have a protected worksheet, to stop people deleting thing
unnecessarily. Although some rows need to be deleted occasionally.

I want to delete these rows using a macro that unprotects the sheet
deletes the row that has been selected and then protects the shee
again.

I created the following macro, which works:

Sub DeleteMealItem()
ActiveSheet.Unprotect
Selection.EntireRow.Delete
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=True
End Sub

But there are some rows in the sheet that i don't want anyone to b
able to delete.

Is there a way to run this so nobody can accidentally delete rows 1 t
8

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Excel Problem - Delete Row Macro

Hi
one way: To prevent any deletion if row 1-8 are within the selection,
try

Sub DeleteMealItem()
If Intersect(Selection, Range("1:8")) Is Nothing Then
ActiveSheet.Unprotect
Selection.EntireRow.Delete
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
else
msgbox "Rows 1- 8 cannot be deleted"
end if
End Sub

Frank


I have a protected worksheet, to stop people deleting things
unnecessarily. Although some rows need to be deleted occasionally.

I want to delete these rows using a macro that unprotects the sheet,
deletes the row that has been selected and then protects the sheet
again.

I created the following macro, which works:

Sub DeleteMealItem()
ActiveSheet.Unprotect
Selection.EntireRow.Delete
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End Sub

But there are some rows in the sheet that i don't want anyone to be
able to delete.

Is there a way to run this so nobody can accidentally delete rows 1

to
8.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel Problem - Delete Row Macro

Thank you very much Frank, that worked fine.

Now i wish i had chosen to do VBA on the course i am doing, it woul
have been more helpfull to me

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Excel Problem - Delete Row Macro

Hi
thanks for the feedback. You may find the following sites interesting:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
http://www.mvps.org/dmcritchie/excel...m#vbatutorials
http://support.microsoft.com/support...01/default.asp

--
Regards
Frank Kabel
Frankfurt, Germany

Thank you very much Frank, that worked fine.

Now i wish i had chosen to do VBA on the course i am doing, it would
have been more helpfull to me.


---
Message posted from http://www.ExcelForum.com/

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
Excel Delete VB Macro Ty Excel Worksheet Functions 9 August 10th 09 03:31 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 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
Excel VBA - Help with a loop, compare, delete problem rippy Excel Programming 0 February 4th 04 03:38 PM
Macro to delete record and validation problem Bob[_40_] Excel Programming 5 December 9th 03 01:35 PM


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