Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

preventing users from adding rows in excel

Status
Not open for further replies.

fenris

Programmer
May 20, 1999
824
CA
I built a bunch of macros to aid users in filling out information in excel spreadsheets. I am wondering how to prevent the user from adding rows with out locking cells. What I have is a timesheet that has a certain number of rows and fits nicely on one sheet of paper. If they require more rows then they are to start a new sheet.

I am wondering does a sheet have an add row event?

Troy Williams B.Eng.
fenris@hotmail.com

 
I don't think that Excel has an AddRow event. The best way to accomplish this is to protect the worksheet. You will have to turn the protection option off on the cells that can accept data. This will preserve the format of the worksheet without limiting data entry. You can toggle the protection from within your macro if needed.

Another option would be to have a macro review the time sheet to check the number of rows. If the max number is exceeded, you can warn the user and force them to fix it before continuing.
 
Thanks for the ideas, they were similar to what I had in mind but I thought I should ask to see if there were better (easier) ways to accomplish what I needed.



Troy Williams B.Eng.
fenris@hotmail.com

 
Take a look at.

Private Sub Workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As Boolean)

By canceling all save events the workbook is essentially 'locked'. Further, you might provide a message box to explain this to the user at that point.




Amiel
amielzz@netscape.net

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top