Detecting when a user deletes a row
If the issue is the print area being bad you might try resetting it in the
before print event to the range with data:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Range("A1", Cells(Cells.Find("*", Range("A1"), , , _
xlByRows, xlPrevious).Row, Cells.Find( _
"*", Range("A1"), , , xlByColumns, xlPrevious) _
.Column)).Name = "Print_area"
End Sub
This code goes in the ThisWorkbook module. As it is now it will fire for
any worksheet in the workbook. If that's an issue you could add code to
check that the right sheet is active.
--
Jim
"Wescotte" wrote in message
ups.com...
|I have a script working using
|
| Private Sub Worksheet_Change(ByVal Target As Excel.Range)
|
| so I can format various cells after the user has entered data...
|
| However when a user deletes an entire row the Worksheet_Change() and
| since no value exist in each cell in that row (because it was just
| deleted) my application resets to the default values. Basically
| repopulating the row so it can never actually be deleted.
|
| Now, my default values are pretty much "" so the row appears to be
| empty to the user however say I had 500 rows and I erased 400 on the
| bottom. If I go to print it will spit out quite a few more empty pages.
|
|
| Now, one solution is to simply not allow for empty rows during the
| printing process just erase them. But I really want the user to have
| the ability to insert their own whitespace to make things easier to
| read.
|
| Really what I believe I need to do is figure out how detect when the
| user is doing a right click on a row and clicking delete. Instead of
| calling Worksheet_Change() perform the actual removal of the row.
|
| Any idea how to do this?
|
|